three
Advanced tools
Comparing version 0.147.0 to 0.148.0
@@ -1200,3 +1200,2 @@ import { | ||
handle.position.copy( this.worldPositionStart ); | ||
handle.visible = !! this.axis; | ||
@@ -1203,0 +1202,0 @@ |
@@ -35,3 +35,3 @@ import { ShaderChunk } from 'three'; | ||
pointLightShadow = pointLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; | ||
#endif | ||
@@ -62,3 +62,4 @@ | ||
spotLightShadow = spotLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; | ||
#endif | ||
@@ -73,3 +74,3 @@ | ||
#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES ) | ||
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES ) | ||
@@ -112,3 +113,3 @@ DirectionalLight directionalLight; | ||
directionalLightShadow = directionalLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
@@ -145,3 +146,3 @@ bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter; | ||
directionalLightShadow = directionalLightShadows[ i ]; | ||
if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
@@ -193,3 +194,3 @@ if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight ); | ||
directionalLightShadow = directionalLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
#endif | ||
@@ -196,0 +197,0 @@ |
@@ -62,4 +62,4 @@ /** | ||
iWidth = Math.round( width * fResolution ); | ||
iHeight = Math.round( height * fResolution ); | ||
iWidth = Math.floor( width * fResolution ); | ||
iHeight = Math.floor( height * fResolution ); | ||
@@ -85,5 +85,2 @@ oCanvas.width = iWidth; | ||
const oStyle = oAscii.style; | ||
oStyle.display = 'inline'; | ||
oStyle.width = Math.round( iWidth / fResolution * iScale ) + 'px'; | ||
oStyle.height = Math.round( iHeight / fResolution * iScale ) + 'px'; | ||
oStyle.whiteSpace = 'pre'; | ||
@@ -256,3 +253,3 @@ oStyle.margin = '0px'; | ||
oAscii.innerHTML = '<tr><td>' + strChars + '</td></tr>'; | ||
oAscii.innerHTML = `<tr><td style="display:block;width:${width}px;height:${height}px;overflow:hidden">${strChars}</td></tr>`; | ||
@@ -259,0 +256,0 @@ // console.timeEnd('rendering'); |
@@ -127,18 +127,29 @@ import { | ||
canvas = canvas || document.createElement( 'canvas' ); | ||
ctx = ctx || canvas.getContext( '2d' ); | ||
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || | ||
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) || | ||
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) || | ||
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) { | ||
canvas.width = image.width; | ||
canvas.height = image.height; | ||
canvas = canvas || document.createElement( 'canvas' ); | ||
ctx = ctx || canvas.getContext( '2d' ); | ||
ctx.drawImage( image, 0, 0 ); | ||
canvas.width = image.width; | ||
canvas.height = image.height; | ||
// Get the base64 encoded data | ||
const base64data = canvas | ||
.toDataURL( `image/${ ext }`, 1 ) | ||
.replace( /^data:image\/(png|jpg);base64,/, '' ); | ||
ctx.drawImage( image, 0, 0 ); | ||
// Convert to a uint8 array | ||
return base64ToBuffer( base64data ); | ||
// Get the base64 encoded data | ||
const base64data = canvas | ||
.toDataURL( `image/${ ext }`, 1 ) | ||
.replace( /^data:image\/(png|jpg);base64,/, '' ); | ||
// Convert to a uint8 array | ||
return base64ToBuffer( base64data ); | ||
} else { | ||
throw new Error( 'THREE.ColladaExporter: No valid image data found. Unable to process texture.' ); | ||
} | ||
} | ||
@@ -361,4 +372,5 @@ | ||
let texid = imageMap.get( tex ); | ||
if ( texid == null ) { | ||
if ( texid === undefined ) { | ||
texid = `image-${ libraryImages.length + 1 }`; | ||
@@ -365,0 +377,0 @@ |
@@ -19,12 +19,14 @@ /** | ||
parse( object, options = { | ||
decodeSpeed: 5, | ||
encodeSpeed: 5, | ||
encoderMethod: DRACOExporter.MESH_EDGEBREAKER_ENCODING, | ||
quantization: [ 16, 8, 8, 8, 8 ], | ||
exportUvs: true, | ||
exportNormals: true, | ||
exportColor: false, | ||
} ) { | ||
parse( object, options = {} ) { | ||
options = Object.assign( { | ||
decodeSpeed: 5, | ||
encodeSpeed: 5, | ||
encoderMethod: DRACOExporter.MESH_EDGEBREAKER_ENCODING, | ||
quantization: [ 16, 8, 8, 8, 8 ], | ||
exportUvs: true, | ||
exportNormals: true, | ||
exportColor: false, | ||
}, options ); | ||
if ( DracoEncoderModule === undefined ) { | ||
@@ -31,0 +33,0 @@ |
@@ -269,10 +269,4 @@ /** | ||
if ( typeof fflate === 'undefined' ) { | ||
const deflate = fflate.zlibSync( tmpBuffer ); | ||
console.error( 'THREE.EXRLoader: External \`fflate.module.js\` required' ); | ||
} | ||
const deflate = fflate.zlibSync( tmpBuffer ); // eslint-disable-line no-undef | ||
return deflate; | ||
@@ -279,0 +273,0 @@ |
@@ -272,2 +272,8 @@ import { | ||
if ( attribute.normalized === true ) { | ||
value = MathUtils.normalize( value, attribute.array ); | ||
} | ||
} | ||
@@ -429,5 +435,5 @@ | ||
*/ | ||
async write( input, onDone, options ) { | ||
async write( input, onDone, options = {} ) { | ||
this.options = Object.assign( {}, { | ||
this.options = Object.assign( { | ||
// default options | ||
@@ -881,2 +887,8 @@ binary: false, | ||
if ( attribute.normalized === true ) { | ||
value = MathUtils.normalize( value, attribute.array ); | ||
} | ||
} | ||
@@ -1071,109 +1083,117 @@ | ||
const writer = this; | ||
const cache = writer.cache; | ||
const json = writer.json; | ||
const options = writer.options; | ||
const pending = writer.pending; | ||
if ( image !== null ) { | ||
if ( ! cache.images.has( image ) ) cache.images.set( image, {} ); | ||
const writer = this; | ||
const cache = writer.cache; | ||
const json = writer.json; | ||
const options = writer.options; | ||
const pending = writer.pending; | ||
const cachedImages = cache.images.get( image ); | ||
if ( ! cache.images.has( image ) ) cache.images.set( image, {} ); | ||
const key = mimeType + ':flipY/' + flipY.toString(); | ||
const cachedImages = cache.images.get( image ); | ||
if ( cachedImages[ key ] !== undefined ) return cachedImages[ key ]; | ||
const key = mimeType + ':flipY/' + flipY.toString(); | ||
if ( ! json.images ) json.images = []; | ||
if ( cachedImages[ key ] !== undefined ) return cachedImages[ key ]; | ||
const imageDef = { mimeType: mimeType }; | ||
if ( ! json.images ) json.images = []; | ||
const canvas = getCanvas(); | ||
const imageDef = { mimeType: mimeType }; | ||
canvas.width = Math.min( image.width, options.maxTextureSize ); | ||
canvas.height = Math.min( image.height, options.maxTextureSize ); | ||
const canvas = getCanvas(); | ||
const ctx = canvas.getContext( '2d' ); | ||
canvas.width = Math.min( image.width, options.maxTextureSize ); | ||
canvas.height = Math.min( image.height, options.maxTextureSize ); | ||
if ( flipY === true ) { | ||
const ctx = canvas.getContext( '2d' ); | ||
ctx.translate( 0, canvas.height ); | ||
ctx.scale( 1, - 1 ); | ||
if ( flipY === true ) { | ||
} | ||
ctx.translate( 0, canvas.height ); | ||
ctx.scale( 1, - 1 ); | ||
if ( image.data !== undefined ) { // THREE.DataTexture | ||
} | ||
if ( format !== RGBAFormat ) { | ||
if ( image.data !== undefined ) { // THREE.DataTexture | ||
console.error( 'GLTFExporter: Only RGBAFormat is supported.' ); | ||
if ( format !== RGBAFormat ) { | ||
} | ||
console.error( 'GLTFExporter: Only RGBAFormat is supported.' ); | ||
if ( image.width > options.maxTextureSize || image.height > options.maxTextureSize ) { | ||
} | ||
console.warn( 'GLTFExporter: Image size is bigger than maxTextureSize', image ); | ||
if ( image.width > options.maxTextureSize || image.height > options.maxTextureSize ) { | ||
} | ||
console.warn( 'GLTFExporter: Image size is bigger than maxTextureSize', image ); | ||
const data = new Uint8ClampedArray( image.height * image.width * 4 ); | ||
} | ||
for ( let i = 0; i < data.length; i += 4 ) { | ||
const data = new Uint8ClampedArray( image.height * image.width * 4 ); | ||
data[ i + 0 ] = image.data[ i + 0 ]; | ||
data[ i + 1 ] = image.data[ i + 1 ]; | ||
data[ i + 2 ] = image.data[ i + 2 ]; | ||
data[ i + 3 ] = image.data[ i + 3 ]; | ||
for ( let i = 0; i < data.length; i += 4 ) { | ||
} | ||
data[ i + 0 ] = image.data[ i + 0 ]; | ||
data[ i + 1 ] = image.data[ i + 1 ]; | ||
data[ i + 2 ] = image.data[ i + 2 ]; | ||
data[ i + 3 ] = image.data[ i + 3 ]; | ||
ctx.putImageData( new ImageData( data, image.width, image.height ), 0, 0 ); | ||
} | ||
} else { | ||
ctx.putImageData( new ImageData( data, image.width, image.height ), 0, 0 ); | ||
ctx.drawImage( image, 0, 0, canvas.width, canvas.height ); | ||
} else { | ||
} | ||
ctx.drawImage( image, 0, 0, canvas.width, canvas.height ); | ||
if ( options.binary === true ) { | ||
} | ||
pending.push( | ||
if ( options.binary === true ) { | ||
getToBlobPromise( canvas, mimeType ) | ||
.then( blob => writer.processBufferViewImage( blob ) ) | ||
.then( bufferViewIndex => { | ||
pending.push( | ||
imageDef.bufferView = bufferViewIndex; | ||
getToBlobPromise( canvas, mimeType ) | ||
.then( blob => writer.processBufferViewImage( blob ) ) | ||
.then( bufferViewIndex => { | ||
} ) | ||
imageDef.bufferView = bufferViewIndex; | ||
); | ||
} ) | ||
} else { | ||
); | ||
if ( canvas.toDataURL !== undefined ) { | ||
} else { | ||
imageDef.uri = canvas.toDataURL( mimeType ); | ||
if ( canvas.toDataURL !== undefined ) { | ||
} else { | ||
imageDef.uri = canvas.toDataURL( mimeType ); | ||
pending.push( | ||
} else { | ||
getToBlobPromise( canvas, mimeType ) | ||
.then( blob => new FileReader().readAsDataURL( blob ) ) | ||
.then( dataURL => { | ||
pending.push( | ||
imageDef.uri = dataURL; | ||
getToBlobPromise( canvas, mimeType ) | ||
.then( blob => new FileReader().readAsDataURL( blob ) ) | ||
.then( dataURL => { | ||
} ) | ||
imageDef.uri = dataURL; | ||
); | ||
} ) | ||
); | ||
} | ||
} | ||
const index = json.images.push( imageDef ) - 1; | ||
cachedImages[ key ] = index; | ||
return index; | ||
} else { | ||
throw new Error( 'THREE.GLTFExporter: No valid image data found. Unable to process texture.' ); | ||
} | ||
const index = json.images.push( imageDef ) - 1; | ||
cachedImages[ key ] = index; | ||
return index; | ||
} | ||
@@ -1613,9 +1633,11 @@ | ||
relativeAttribute.setXYZ( | ||
j, | ||
attribute.getX( j ) - baseAttribute.getX( j ), | ||
attribute.getY( j ) - baseAttribute.getY( j ), | ||
attribute.getZ( j ) - baseAttribute.getZ( j ) | ||
); | ||
for ( let a = 0; a < attribute.itemSize; a ++ ) { | ||
if ( a === 0 ) relativeAttribute.setX( j, attribute.getX( j ) - baseAttribute.getX( j ) ); | ||
if ( a === 1 ) relativeAttribute.setY( j, attribute.getY( j ) - baseAttribute.getY( j ) ); | ||
if ( a === 2 ) relativeAttribute.setZ( j, attribute.getZ( j ) - baseAttribute.getZ( j ) ); | ||
if ( a === 3 ) relativeAttribute.setW( j, attribute.getW( j ) - baseAttribute.getW( j ) ); | ||
} | ||
} | ||
@@ -1622,0 +1644,0 @@ |
@@ -160,3 +160,3 @@ import { | ||
const encoder = new MMDParser.CharsetEncoder(); // eslint-disable-line no-undef | ||
const encoder = new MMDParser.CharsetEncoder(); | ||
const table = encoder.s2uTable; | ||
@@ -163,0 +163,0 @@ u2sTable = {}; |
@@ -22,3 +22,3 @@ import { | ||
parse( object, onDone, options ) { | ||
parse( object, onDone, options = {} ) { | ||
@@ -25,0 +25,0 @@ // Iterate over the valid meshes in the object |
@@ -16,4 +16,8 @@ import { Vector3 } from 'three'; | ||
const binary = options.binary !== undefined ? options.binary : false; | ||
options = Object.assign( { | ||
binary: false | ||
}, options ); | ||
const binary = options.binary; | ||
// | ||
@@ -20,0 +24,0 @@ |
@@ -9,4 +9,11 @@ import { | ||
async parse( scene, options = { ar: { anchoring: { type: 'plane' }, planeAnchoring: { alignment: 'horizontal' } } } ) { | ||
async parse( scene, options = {} ) { | ||
options = Object.assign( { | ||
ar: { | ||
anchoring: { type: 'plane' }, | ||
planeAnchoring: { alignment: 'horizontal' } | ||
} | ||
}, options ); | ||
const files = {}; | ||
@@ -160,2 +167,6 @@ const modelFileName = 'model.usda'; | ||
} else { | ||
throw new Error( 'THREE.USDZExporter: No valid image data found. Unable to process texture.' ); | ||
} | ||
@@ -162,0 +173,0 @@ |
@@ -18,8 +18,2 @@ import { | ||
if ( ConvexHull === undefined ) { | ||
console.error( 'THREE.ConvexGeometry: ConvexGeometry relies on ConvexHull' ); | ||
} | ||
const convexHull = new ConvexHull().setFromPoints( points ); | ||
@@ -26,0 +20,0 @@ |
/** | ||
* lil-gui | ||
* https://lil-gui.georgealways.com | ||
* @version 0.16.0 | ||
* @version 0.17.0 | ||
* @author George Michael Brower | ||
* @license MIT | ||
*/ | ||
class t{constructor(i,e,s,n,r="div"){this.parent=i,this.object=e,this.property=s,this._disabled=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),t.nextNameID=t.nextNameID||0,this.$name.id="lil-gui-name-"+ ++t.nextNameID,this.$widget=document.createElement(r),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(s)}name(t){return this._name=t,this.$name.innerHTML=t,this}onChange(t){return this._onChange=t,this}_callOnChange(){this.parent._callOnChange(this),void 0!==this._onChange&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),void 0!==this._onFinishChange&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(t=!0){return this.disable(!t)}disable(t=!0){return t===this._disabled||(this._disabled=t,this.domElement.classList.toggle("disabled",t),this.$disable.toggleAttribute("disabled",t)),this}options(t){const i=this.parent.add(this.object,this.property,t);return i.name(this._name),this.destroy(),i}min(t){return this}max(t){return this}step(t){return this}listen(t=!0){return this._listening=t,void 0!==this._listenCallbackID&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback),this.updateDisplay()}getValue(){return this.object[this.property]}setValue(t){return this.object[this.property]=t,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(t){return this.setValue(t),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class i extends t{constructor(t,i,e){super(t,i,e,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function e(t){let i,e;return(i=t.match(/(#|0x)?([a-f0-9]{6})/i))?e=i[2]:(i=t.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?e=parseInt(i[1]).toString(16).padStart(2,0)+parseInt(i[2]).toString(16).padStart(2,0)+parseInt(i[3]).toString(16).padStart(2,0):(i=t.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(e=i[1]+i[1]+i[2]+i[2]+i[3]+i[3]),!!e&&"#"+e}const s={isPrimitive:!0,match:t=>"string"==typeof t,fromHexString:e,toHexString:e},n={isPrimitive:!0,match:t=>"number"==typeof t,fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},r={isPrimitive:!1,match:Array.isArray,fromHexString(t,i,e=1){const s=n.fromHexString(t);i[0]=(s>>16&255)/255*e,i[1]=(s>>8&255)/255*e,i[2]=(255&s)/255*e},toHexString:([t,i,e],s=1)=>n.toHexString(t*(s=255/s)<<16^i*s<<8^e*s<<0)},l={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,i,e=1){const s=n.fromHexString(t);i.r=(s>>16&255)/255*e,i.g=(s>>8&255)/255*e,i.b=(255&s)/255*e},toHexString:({r:t,g:i,b:e},s=1)=>n.toHexString(t*(s=255/s)<<16^i*s<<8^e*s<<0)},o=[s,n,r,l];class a extends t{constructor(t,i,s,n){var r;super(t,i,s,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(r=this.initialValue,o.find(t=>t.match(r))),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const t=e(this.$text.value);t&&this._setValueFromHexString(t)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){const i=this._format.fromHexString(t);this.setValue(i)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class h extends t{constructor(t,i,e){super(t,i,e,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",t=>{t.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{}),this.$disable=this.$button}}class d extends t{constructor(t,i,e,s,n,r){super(t,i,e,"number"),this._initInput(),this.min(s),this.max(n);const l=void 0!==r;this.step(l?r:this._getImplicitStep(),l),this.updateDisplay()}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,i=!0){return this._step=t,this._stepExplicit=i,this}updateDisplay(){const t=this.getValue();if(this._hasSlider){let i=(t-this._min)/(this._max-this._min);i=Math.max(0,Math.min(i,1)),this.$fill.style.width=100*i+"%"}return this._inputFocused||(this.$input.value=t),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=t=>{const i=parseFloat(this.$input.value);isNaN(i)||(this._snapClampSetValue(i+t),this.$input.value=this.getValue())};let i,e,s,n,r,l=!1;const o=t=>{if(l){const s=t.clientX-i,n=t.clientY-e;Math.abs(n)>5?(t.preventDefault(),this.$input.blur(),l=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(s)>5&&a()}if(!l){const i=t.clientY-s;r-=i*this._step*this._arrowKeyMultiplier(t),n+r>this._max?r=this._max-n:n+r<this._min&&(r=this._min-n),this._snapClampSetValue(n+r)}s=t.clientY},a=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a)};this.$input.addEventListener("input",()=>{const t=parseFloat(this.$input.value);isNaN(t)||this.setValue(this._clamp(t))}),this.$input.addEventListener("keydown",i=>{"Enter"===i.code&&this.$input.blur(),"ArrowUp"===i.code&&(i.preventDefault(),t(this._step*this._arrowKeyMultiplier(i))),"ArrowDown"===i.code&&(i.preventDefault(),t(this._step*this._arrowKeyMultiplier(i)*-1))}),this.$input.addEventListener("wheel",i=>{this._inputFocused&&(i.preventDefault(),t(this._step*this._normalizeMouseWheel(i)))}),this.$input.addEventListener("mousedown",t=>{i=t.clientX,e=s=t.clientY,l=!0,n=this.getValue(),r=0,window.addEventListener("mousemove",o),window.addEventListener("mouseup",a)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const t=t=>{const i=this.$slider.getBoundingClientRect();let e=(s=t,n=i.left,r=i.right,l=this._min,o=this._max,(s-n)/(r-n)*(o-l)+l);var s,n,r,l,o;this._snapClampSetValue(e)},i=i=>{t(i.clientX)},e=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",e)};let s,n,r=!1;const l=i=>{i.preventDefault(),this._setDraggingStyle(!0),t(i.touches[0].clientX),r=!1},o=i=>{if(r){const t=i.touches[0].clientX-s,e=i.touches[0].clientY-n;Math.abs(t)>Math.abs(e)?l(i):(window.removeEventListener("touchmove",o),window.removeEventListener("touchend",a))}else i.preventDefault(),t(i.touches[0].clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",o),window.removeEventListener("touchend",a)},h=this._callOnFinishChange.bind(this);let d;this.$slider.addEventListener("mousedown",s=>{this._setDraggingStyle(!0),t(s.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",e)}),this.$slider.addEventListener("touchstart",t=>{t.touches.length>1||(this._hasScrollBar?(s=t.touches[0].clientX,n=t.touches[0].clientY,r=!0):l(t),window.addEventListener("touchmove",o),window.addEventListener("touchend",a))}),this.$slider.addEventListener("wheel",t=>{if(Math.abs(t.deltaX)<Math.abs(t.deltaY)&&this._hasScrollBar)return;t.preventDefault();const i=this._normalizeMouseWheel(t)*this._step;this._snapClampSetValue(this.getValue()+i),this.$input.value=this.getValue(),clearTimeout(d),d=setTimeout(h,400)})}_setDraggingStyle(t,i="horizontal"){this.$slider&&this.$slider.classList.toggle("active",t),document.body.classList.toggle("lil-gui-dragging",t),document.body.classList.toggle("lil-gui-"+i,t)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(t){let{deltaX:i,deltaY:e}=t;Math.floor(t.deltaY)!==t.deltaY&&t.wheelDelta&&(i=0,e=-t.wheelDelta/120,e*=this._stepExplicit?1:10);return i+-e}_arrowKeyMultiplier(t){let i=this._stepExplicit?1:10;return t.shiftKey?i*=10:t.altKey&&(i/=10),i}_snap(t){const i=Math.round(t/this._step)*this._step;return parseFloat(i.toPrecision(15))}_clamp(t){return t<this._min&&(t=this._min),t>this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){const t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return void 0!==this._min}get _hasMax(){return void 0!==this._max}}class c extends t{constructor(t,i,e,s){super(t,i,e,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(s)?s:Object.values(s),this._names=Array.isArray(s)?s:Object.keys(s),this._names.forEach(t=>{const i=document.createElement("option");i.innerHTML=t,this.$select.appendChild(i)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const t=this.getValue(),i=this._values.indexOf(t);return this.$select.selectedIndex=i,this.$display.innerHTML=-1===i?t:this._names[i],this}}class u extends t{constructor(t,i,e){super(t,i,e,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",t=>{"Enter"===t.code&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let p=!1;class g{constructor({parent:t,autoPlace:i=void 0===t,container:e,width:s,title:n="Controls",injectStyles:r=!0,touchStyles:l=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",t=>{"Enter"!==t.code&&"Space"!==t.code||(t.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(n),l&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!p&&r&&(!function(t){const i=document.createElement("style");i.innerHTML=t;const e=document.querySelector("head link[rel=stylesheet], head style");e?document.head.insertBefore(i,e):document.head.appendChild(i)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),p=!0),e?e.appendChild(this.domElement):i&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),s&&this.domElement.style.setProperty("--width",s+"px"),this.domElement.addEventListener("keydown",t=>t.stopPropagation()),this.domElement.addEventListener("keyup",t=>t.stopPropagation())}add(t,e,s,n,r){if(Object(s)===s)return new c(this,t,e,s);const l=t[e];switch(typeof l){case"number":return new d(this,t,e,s,n,r);case"boolean":return new i(this,t,e);case"string":return new u(this,t,e);case"function":return new h(this,t,e)}console.error("gui.add failed\n\tproperty:",e,"\n\tobject:",t,"\n\tvalue:",l)}addColor(t,i,e=1){return new a(this,t,i,e)}addFolder(t){return new g({parent:this,title:t})}load(t,i=!0){return t.controllers&&this.controllers.forEach(i=>{i instanceof h||i._name in t.controllers&&i.load(t.controllers[i._name])}),i&&t.folders&&this.folders.forEach(i=>{i._title in t.folders&&i.load(t.folders[i._title])}),this}save(t=!0){const i={controllers:{},folders:{}};return this.controllers.forEach(t=>{if(!(t instanceof h)){if(t._name in i.controllers)throw new Error(`Cannot save GUI with duplicate property "${t._name}"`);i.controllers[t._name]=t.save()}}),t&&this.folders.forEach(t=>{if(t._title in i.folders)throw new Error(`Cannot save GUI with duplicate folder "${t._title}"`);i.folders[t._title]=t.save()}),i}open(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const i=this.$children.clientHeight;this.$children.style.height=i+"px",this.domElement.classList.add("transition");const e=t=>{t.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",e))};this.$children.addEventListener("transitionend",e);const s=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=s+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(t=>t.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),void 0!==this._onChange&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),void 0!==this._onFinishChange&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(i=>{t=t.concat(i.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(i=>{t=t.concat(i.foldersRecursive())}),t}}export default g;export{i as BooleanController,a as ColorController,t as Controller,h as FunctionController,g as GUI,d as NumberController,c as OptionController,u as StringController}; | ||
class t{constructor(i,e,s,n,l="div"){this.parent=i,this.object=e,this.property=s,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(n),this.$name=document.createElement("div"),this.$name.classList.add("name"),t.nextNameID=t.nextNameID||0,this.$name.id="lil-gui-name-"+ ++t.nextNameID,this.$widget=document.createElement(l),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(s)}name(t){return this._name=t,this.$name.innerHTML=t,this}onChange(t){return this._onChange=t,this}_callOnChange(){this.parent._callOnChange(this),void 0!==this._onChange&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),void 0!==this._onFinishChange&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(t=!0){return this.disable(!t)}disable(t=!0){return t===this._disabled||(this._disabled=t,this.domElement.classList.toggle("disabled",t),this.$disable.toggleAttribute("disabled",t)),this}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(t){const i=this.parent.add(this.object,this.property,t);return i.name(this._name),this.destroy(),i}min(t){return this}max(t){return this}step(t){return this}decimals(t){return this}listen(t=!0){return this._listening=t,void 0!==this._listenCallbackID&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const t=this.save();t!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=t}getValue(){return this.object[this.property]}setValue(t){return this.object[this.property]=t,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(t){return this.setValue(t),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}}class i extends t{constructor(t,i,e){super(t,i,e,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function e(t){let i,e;return(i=t.match(/(#|0x)?([a-f0-9]{6})/i))?e=i[2]:(i=t.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?e=parseInt(i[1]).toString(16).padStart(2,0)+parseInt(i[2]).toString(16).padStart(2,0)+parseInt(i[3]).toString(16).padStart(2,0):(i=t.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(e=i[1]+i[1]+i[2]+i[2]+i[3]+i[3]),!!e&&"#"+e}const s={isPrimitive:!0,match:t=>"string"==typeof t,fromHexString:e,toHexString:e},n={isPrimitive:!0,match:t=>"number"==typeof t,fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},l={isPrimitive:!1,match:Array.isArray,fromHexString(t,i,e=1){const s=n.fromHexString(t);i[0]=(s>>16&255)/255*e,i[1]=(s>>8&255)/255*e,i[2]=(255&s)/255*e},toHexString:([t,i,e],s=1)=>n.toHexString(t*(s=255/s)<<16^i*s<<8^e*s<<0)},r={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,i,e=1){const s=n.fromHexString(t);i.r=(s>>16&255)/255*e,i.g=(s>>8&255)/255*e,i.b=(255&s)/255*e},toHexString:({r:t,g:i,b:e},s=1)=>n.toHexString(t*(s=255/s)<<16^i*s<<8^e*s<<0)},o=[s,n,l,r];class a extends t{constructor(t,i,s,n){var l;super(t,i,s,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(l=this.initialValue,o.find(t=>t.match(l))),this._rgbScale=n,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const t=e(this.$text.value);t&&this._setValueFromHexString(t)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){const i=this._format.fromHexString(t);this.setValue(i)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class h extends t{constructor(t,i,e){super(t,i,e,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",t=>{t.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class d extends t{constructor(t,i,e,s,n,l){super(t,i,e,"number"),this._initInput(),this.min(s),this.max(n);const r=void 0!==l;this.step(r?l:this._getImplicitStep(),r),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,i=!0){return this._step=t,this._stepExplicit=i,this}updateDisplay(){const t=this.getValue();if(this._hasSlider){let i=(t-this._min)/(this._max-this._min);i=Math.max(0,Math.min(i,1)),this.$fill.style.width=100*i+"%"}return this._inputFocused||(this.$input.value=void 0===this._decimals?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=t=>{const i=parseFloat(this.$input.value);isNaN(i)||(this._snapClampSetValue(i+t),this.$input.value=this.getValue())};let i,e,s,n,l,r=!1;const o=t=>{if(r){const s=t.clientX-i,n=t.clientY-e;Math.abs(n)>5?(t.preventDefault(),this.$input.blur(),r=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(s)>5&&a()}if(!r){const i=t.clientY-s;l-=i*this._step*this._arrowKeyMultiplier(t),n+l>this._max?l=this._max-n:n+l<this._min&&(l=this._min-n),this._snapClampSetValue(n+l)}s=t.clientY},a=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",a)};this.$input.addEventListener("input",()=>{let t=parseFloat(this.$input.value);isNaN(t)||(this._stepExplicit&&(t=this._snap(t)),this.setValue(this._clamp(t)))}),this.$input.addEventListener("keydown",i=>{"Enter"===i.code&&this.$input.blur(),"ArrowUp"===i.code&&(i.preventDefault(),t(this._step*this._arrowKeyMultiplier(i))),"ArrowDown"===i.code&&(i.preventDefault(),t(this._step*this._arrowKeyMultiplier(i)*-1))}),this.$input.addEventListener("wheel",i=>{this._inputFocused&&(i.preventDefault(),t(this._step*this._normalizeMouseWheel(i)))},{passive:!1}),this.$input.addEventListener("mousedown",t=>{i=t.clientX,e=s=t.clientY,r=!0,n=this.getValue(),l=0,window.addEventListener("mousemove",o),window.addEventListener("mouseup",a)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const t=t=>{const i=this.$slider.getBoundingClientRect();let e=(s=t,n=i.left,l=i.right,r=this._min,o=this._max,(s-n)/(l-n)*(o-r)+r);var s,n,l,r,o;this._snapClampSetValue(e)},i=i=>{t(i.clientX)},e=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",e)};let s,n,l=!1;const r=i=>{i.preventDefault(),this._setDraggingStyle(!0),t(i.touches[0].clientX),l=!1},o=i=>{if(l){const t=i.touches[0].clientX-s,e=i.touches[0].clientY-n;Math.abs(t)>Math.abs(e)?r(i):(window.removeEventListener("touchmove",o),window.removeEventListener("touchend",a))}else i.preventDefault(),t(i.touches[0].clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",o),window.removeEventListener("touchend",a)},h=this._callOnFinishChange.bind(this);let d;this.$slider.addEventListener("mousedown",s=>{this._setDraggingStyle(!0),t(s.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",e)}),this.$slider.addEventListener("touchstart",t=>{t.touches.length>1||(this._hasScrollBar?(s=t.touches[0].clientX,n=t.touches[0].clientY,l=!0):r(t),window.addEventListener("touchmove",o,{passive:!1}),window.addEventListener("touchend",a))},{passive:!1}),this.$slider.addEventListener("wheel",t=>{if(Math.abs(t.deltaX)<Math.abs(t.deltaY)&&this._hasScrollBar)return;t.preventDefault();const i=this._normalizeMouseWheel(t)*this._step;this._snapClampSetValue(this.getValue()+i),this.$input.value=this.getValue(),clearTimeout(d),d=setTimeout(h,400)},{passive:!1})}_setDraggingStyle(t,i="horizontal"){this.$slider&&this.$slider.classList.toggle("active",t),document.body.classList.toggle("lil-gui-dragging",t),document.body.classList.toggle("lil-gui-"+i,t)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(t){let{deltaX:i,deltaY:e}=t;Math.floor(t.deltaY)!==t.deltaY&&t.wheelDelta&&(i=0,e=-t.wheelDelta/120,e*=this._stepExplicit?1:10);return i+-e}_arrowKeyMultiplier(t){let i=this._stepExplicit?1:10;return t.shiftKey?i*=10:t.altKey&&(i/=10),i}_snap(t){const i=Math.round(t/this._step)*this._step;return parseFloat(i.toPrecision(15))}_clamp(t){return t<this._min&&(t=this._min),t>this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){const t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return void 0!==this._min}get _hasMax(){return void 0!==this._max}}class c extends t{constructor(t,i,e,s){super(t,i,e,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(s)?s:Object.values(s),this._names=Array.isArray(s)?s:Object.keys(s),this._names.forEach(t=>{const i=document.createElement("option");i.innerHTML=t,this.$select.appendChild(i)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const t=this.getValue(),i=this._values.indexOf(t);return this.$select.selectedIndex=i,this.$display.innerHTML=-1===i?t:this._names[i],this}}class u extends t{constructor(t,i,e){super(t,i,e,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",t=>{"Enter"===t.code&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let p=!1;class g{constructor({parent:t,autoPlace:i=void 0===t,container:e,width:s,title:n="Controls",injectStyles:l=!0,touchStyles:r=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",t=>{"Enter"!==t.code&&"Space"!==t.code||(t.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(n),r&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!p&&l&&(!function(t){const i=document.createElement("style");i.innerHTML=t;const e=document.querySelector("head link[rel=stylesheet], head style");e?document.head.insertBefore(i,e):document.head.appendChild(i)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),p=!0),e?e.appendChild(this.domElement):i&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),s&&this.domElement.style.setProperty("--width",s+"px"),this.domElement.addEventListener("keydown",t=>t.stopPropagation()),this.domElement.addEventListener("keyup",t=>t.stopPropagation())}add(t,e,s,n,l){if(Object(s)===s)return new c(this,t,e,s);const r=t[e];switch(typeof r){case"number":return new d(this,t,e,s,n,l);case"boolean":return new i(this,t,e);case"string":return new u(this,t,e);case"function":return new h(this,t,e)}console.error("gui.add failed\n\tproperty:",e,"\n\tobject:",t,"\n\tvalue:",r)}addColor(t,i,e=1){return new a(this,t,i,e)}addFolder(t){return new g({parent:this,title:t})}load(t,i=!0){return t.controllers&&this.controllers.forEach(i=>{i instanceof h||i._name in t.controllers&&i.load(t.controllers[i._name])}),i&&t.folders&&this.folders.forEach(i=>{i._title in t.folders&&i.load(t.folders[i._title])}),this}save(t=!0){const i={controllers:{},folders:{}};return this.controllers.forEach(t=>{if(!(t instanceof h)){if(t._name in i.controllers)throw new Error(`Cannot save GUI with duplicate property "${t._name}"`);i.controllers[t._name]=t.save()}}),t&&this.folders.forEach(t=>{if(t._title in i.folders)throw new Error(`Cannot save GUI with duplicate folder "${t._title}"`);i.folders[t._title]=t.save()}),i}open(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const i=this.$children.clientHeight;this.$children.style.height=i+"px",this.domElement.classList.add("transition");const e=t=>{t.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",e))};this.$children.addEventListener("transitionend",e);const s=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=s+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(t=>t.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),void 0!==this._onChange&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),void 0!==this._onFinishChange&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(i=>{t=t.concat(i.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(i=>{t=t.concat(i.foldersRecursive())}),t}}export default g;export{i as BooleanController,a as ColorController,t as Controller,h as FunctionController,g as GUI,d as NumberController,c as OptionController,u as StringController}; |
@@ -32,3 +32,3 @@ import { | ||
let _ray, _instanceStart, _instanceEnd, _lineWidth; | ||
let _ray, _lineWidth; | ||
@@ -56,7 +56,11 @@ // Returns the margin required to expand by in world space given the distance from the camera, | ||
const matrixWorld = lineSegments.matrixWorld; | ||
const geometry = lineSegments.geometry; | ||
const instanceStart = geometry.attributes.instanceStart; | ||
const instanceEnd = geometry.attributes.instanceEnd; | ||
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count ); | ||
for ( let i = 0, l = _instanceStart.count; i < l; i ++ ) { | ||
for ( let i = 0, l = segmentCount; i < l; i ++ ) { | ||
_line.start.fromBufferAttribute( _instanceStart, i ); | ||
_line.end.fromBufferAttribute( _instanceEnd, i ); | ||
_line.start.fromBufferAttribute( instanceStart, i ); | ||
_line.end.fromBufferAttribute( instanceEnd, i ); | ||
@@ -100,2 +104,3 @@ _line.applyMatrix4( matrixWorld ); | ||
const instanceEnd = geometry.attributes.instanceEnd; | ||
const segmentCount = Math.min( geometry.instanceCount, instanceStart.count ); | ||
@@ -126,3 +131,3 @@ const near = - camera.near; | ||
for ( let i = 0, l = instanceStart.count; i < l; i ++ ) { | ||
for ( let i = 0, l = segmentCount; i < l; i ++ ) { | ||
@@ -286,5 +291,2 @@ _start4.fromBufferAttribute( instanceStart, i ); | ||
_instanceStart = geometry.attributes.instanceStart; | ||
_instanceEnd = geometry.attributes.instanceEnd; | ||
// check if we intersect the sphere bounds | ||
@@ -291,0 +293,0 @@ if ( geometry.boundingSphere === null ) { |
@@ -109,3 +109,3 @@ import { | ||
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef | ||
zip = fflate.unzipSync( new Uint8Array( data ) ); | ||
@@ -112,0 +112,0 @@ } catch ( e ) { |
@@ -89,3 +89,3 @@ import { | ||
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef | ||
zip = fflate.unzipSync( new Uint8Array( data ) ); | ||
@@ -92,0 +92,0 @@ } catch ( e ) { |
@@ -1255,9 +1255,3 @@ import { | ||
if ( typeof fflate === 'undefined' ) { | ||
console.error( 'THREE.EXRLoader: External library fflate.min.js required.' ); | ||
} | ||
const rawBuffer = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef | ||
const rawBuffer = fflate.unzlibSync( compressed ); | ||
const tmpBuffer = new Uint8Array( rawBuffer.length ); | ||
@@ -1379,10 +1373,4 @@ | ||
if ( typeof fflate === 'undefined' ) { | ||
const rawBuffer = fflate.unzlibSync( compressed ); | ||
console.error( 'THREE.EXRLoader: External library fflate.min.js required.' ); | ||
} | ||
const rawBuffer = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef | ||
const sz = info.lines * info.channels * info.width; | ||
@@ -1567,3 +1555,3 @@ const tmpBuffer = ( info.type == 1 ) ? new Uint16Array( sz ) : new Uint32Array( sz ); | ||
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.totalAcUncompressedCount ); | ||
const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef | ||
const data = fflate.unzlibSync( compressed ); | ||
acBuffer = new Uint16Array( data.buffer ); | ||
@@ -1595,3 +1583,3 @@ inOffset.value += dwaHeader.totalAcUncompressedCount; | ||
const compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize ); | ||
const data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef | ||
const data = fflate.unzlibSync( compressed ); | ||
rleBuffer = decodeRunLength( data.buffer ); | ||
@@ -1598,0 +1586,0 @@ |
import { | ||
BufferGeometry, | ||
Euler, | ||
FileLoader, | ||
@@ -254,3 +253,3 @@ Float32BufferAttribute, | ||
object.quaternion.setFromEuler( new Euler( - Math.PI / 2, 0, 0 ) ); | ||
object.rotation.set( - Math.PI / 2, 0, 0 ); | ||
@@ -257,0 +256,0 @@ return object; |
@@ -89,7 +89,7 @@ import { | ||
const zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef | ||
const zip = fflate.unzipSync( new Uint8Array( data ) ); | ||
if ( zip[ 'doc.kml' ] ) { | ||
const xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef | ||
const xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); | ||
@@ -101,3 +101,3 @@ const model = xml.querySelector( 'Placemark Model Link href' ); | ||
const loader = new ColladaLoader( manager ); | ||
return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); // eslint-disable-line no-undef | ||
return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); | ||
@@ -117,3 +117,3 @@ } | ||
const loader = new ColladaLoader( manager ); | ||
return loader.parse( fflate.strFromU8( zip[ path ] ) ); // eslint-disable-line no-undef | ||
return loader.parse( fflate.strFromU8( zip[ path ] ) ); | ||
@@ -120,0 +120,0 @@ } |
@@ -339,10 +339,4 @@ import { | ||
if ( typeof MMDParser === 'undefined' ) { | ||
this.parser = new MMDParser.Parser(); | ||
throw new Error( 'THREE.MMDLoader: Import MMDParser https://github.com/takahirox/mmd-parser' ); | ||
} | ||
this.parser = new MMDParser.Parser(); // eslint-disable-line no-undef | ||
} | ||
@@ -2086,2 +2080,4 @@ | ||
this.type = 'MMDToonMaterial'; | ||
this._matcapCombine = AddOperation; | ||
@@ -2088,0 +2084,0 @@ this.emissiveIntensity = 1.0; |
@@ -330,3 +330,3 @@ import { | ||
// here we start the unzipping and get a typed Uint8Array back | ||
_data = fflate.gunzipSync( new Uint8Array( _data ) );// eslint-disable-line no-undef | ||
_data = fflate.gunzipSync( new Uint8Array( _data ) ); | ||
@@ -333,0 +333,0 @@ } else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) { |
@@ -208,11 +208,4 @@ import { | ||
if ( typeof opentype === 'undefined' ) { | ||
return convert( opentype.parse( arraybuffer ), this.reversed ); | ||
console.warn( 'THREE.TTFLoader: The loader requires opentype.js. Make sure it\'s included before using the loader.' ); | ||
return null; | ||
} | ||
return convert( opentype.parse( arraybuffer ), this.reversed ); // eslint-disable-line no-undef | ||
} | ||
@@ -219,0 +212,0 @@ |
@@ -208,3 +208,3 @@ import { | ||
const zip = fflate.unzipSync( new Uint8Array( buffer ) ); // eslint-disable-line no-undef | ||
const zip = fflate.unzipSync( new Uint8Array( buffer ) ); | ||
@@ -211,0 +211,0 @@ // console.log( zip ); |
@@ -783,3 +783,3 @@ import { | ||
const data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef | ||
const data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); | ||
content = data.buffer; | ||
@@ -786,0 +786,0 @@ |
@@ -7,2 +7,4 @@ import TextureNode from './TextureNode.js'; | ||
let defaultUV; | ||
class CubeTextureNode extends TextureNode { | ||
@@ -24,26 +26,8 @@ | ||
getConstructHash( builder ) { | ||
getDefaultUV() { | ||
return `${ this.uuid } / ${ builder.context.environmentContext?.uuid || '' }`; | ||
defaultUV ||= new ReflectVectorNode(); | ||
} | ||
return defaultUV; | ||
construct( builder ) { | ||
const properties = builder.getNodeProperties( this ); | ||
const uvNode = this.uvNode || builder.context.uvNode || new ReflectVectorNode(); | ||
let levelNode = this.levelNode || builder.context.levelNode; | ||
if ( levelNode?.isNode === true ) { | ||
const texture = this.value; | ||
levelNode = builder.context.levelShaderNode ? builder.context.levelShaderNode.call( { texture, levelNode }, builder ) : levelNode; | ||
} | ||
properties.uvNode = uvNode; | ||
properties.levelNode = levelNode; | ||
} | ||
@@ -77,5 +61,5 @@ | ||
let snippet = nodeData.snippet; | ||
let propertyName = nodeData.propertyName; | ||
if ( snippet === undefined || builder.context.tempRead === false ) { | ||
if ( propertyName === undefined ) { | ||
@@ -86,4 +70,10 @@ const uvNodeObject = nodeObject( uvNode ); | ||
if ( levelNode ) { | ||
const nodeVar = builder.getVarFromNode( this, 'vec4' ); | ||
propertyName = builder.getPropertyName( nodeVar ); | ||
let snippet = null; | ||
if ( levelNode?.isNode === true) { | ||
const levelSnippet = levelNode.build( builder, 'float' ); | ||
@@ -99,7 +89,10 @@ | ||
builder.addFlowCode( `${propertyName} = ${snippet}` ); | ||
nodeData.snippet = snippet; | ||
nodeData.propertyName = propertyName; | ||
} | ||
return builder.format( snippet, 'vec4', output ); | ||
return builder.format( propertyName, 'vec4', output ); | ||
@@ -106,0 +99,0 @@ } |
@@ -50,3 +50,3 @@ import Node from '../core/Node.js'; | ||
generate( builder, output ) { | ||
construct( builder ) { | ||
@@ -147,3 +147,3 @@ const material = builder.context.material; | ||
return node.build( builder, output ); | ||
return node; | ||
@@ -150,0 +150,0 @@ } |
@@ -24,2 +24,8 @@ import Node from '../core/Node.js'; | ||
isGlobal() { | ||
return true; | ||
} | ||
getHash( /*builder*/ ) { | ||
@@ -26,0 +32,0 @@ |
@@ -25,2 +25,8 @@ import Node from '../core/Node.js'; | ||
isGlobal() { | ||
return true; | ||
} | ||
getHash( /*builder*/ ) { | ||
@@ -27,0 +33,0 @@ |
import UniformNode from '../core/UniformNode.js'; | ||
import UVNode from './UVNode.js'; | ||
let defaultUV; | ||
class TextureNode extends UniformNode { | ||
constructor( value, uvNode = new UVNode(), levelNode = null ) { | ||
constructor( value, uvNode = null, levelNode = null ) { | ||
@@ -29,4 +31,47 @@ super( value, 'vec4' ); | ||
getDefaultUV() { | ||
defaultUV ||= new UVNode(); | ||
return defaultUV; | ||
} | ||
construct( builder ) { | ||
const properties = builder.getNodeProperties( this ); | ||
// | ||
let uvNode = this.uvNode; | ||
if ( uvNode === null && builder.context.getUVNode ) { | ||
uvNode = builder.context.getUVNode( this ) | ||
} | ||
uvNode ||= this.getDefaultUV(); | ||
// | ||
let levelNode = this.levelNode; | ||
if ( levelNode === null && builder.context.getSamplerLevelNode ) { | ||
levelNode = builder.context.getSamplerLevelNode( this ); | ||
} | ||
// | ||
properties.uvNode = uvNode; | ||
properties.levelNode = levelNode ? builder.context.getMIPLevelAlgorithmNode( this, levelNode ) : null; | ||
} | ||
generate( builder, output ) { | ||
const { uvNode, levelNode } = builder.getNodeProperties( this ); | ||
const texture = this.value; | ||
@@ -54,11 +99,15 @@ | ||
let snippet = nodeData.snippet; | ||
let propertyName = nodeData.propertyName; | ||
if ( snippet === undefined ) { | ||
if ( propertyName === undefined ) { | ||
const uvSnippet = this.uvNode.build( builder, 'vec2' ); | ||
const levelNode = this.levelNode; | ||
const uvSnippet = uvNode.build( builder, 'vec2' ); | ||
const nodeVar = builder.getVarFromNode( this, 'vec4' ); | ||
if ( levelNode !== null ) { | ||
propertyName = builder.getPropertyName( nodeVar ); | ||
let snippet = null; | ||
if ( levelNode?.isNode === true) { | ||
const levelSnippet = levelNode.build( builder, 'float' ); | ||
@@ -74,7 +123,10 @@ | ||
builder.addFlowCode( `${propertyName} = ${snippet}` ); | ||
nodeData.snippet = snippet; | ||
nodeData.propertyName = propertyName; | ||
} | ||
return builder.format( snippet, 'vec4', output ); | ||
return builder.format( propertyName, 'vec4', output ); | ||
@@ -81,0 +133,0 @@ } |
@@ -29,2 +29,8 @@ import { NodeUpdateType } from './constants.js'; | ||
isGlobal( /*builder*/ ) { | ||
return false; | ||
} | ||
getChildren() { | ||
@@ -54,2 +60,16 @@ | ||
} else if ( typeof object === 'object' ) { | ||
for ( const property in object ) { | ||
const child = object[ property ]; | ||
if ( child?.isNode === true ) { | ||
children.push( child ); | ||
} | ||
} | ||
} | ||
@@ -87,8 +107,2 @@ | ||
getConstructHash( /*builder*/ ) { | ||
return this.uuid; | ||
} | ||
getReference( builder ) { | ||
@@ -95,0 +109,0 @@ |
@@ -7,2 +7,3 @@ import NodeUniform from './NodeUniform.js'; | ||
import NodeKeywords from './NodeKeywords.js'; | ||
import NodeCache from './NodeCache.js'; | ||
import { NodeUpdateType } from './constants.js'; | ||
@@ -12,3 +13,6 @@ | ||
import { mul, maxMipLevel } from '../shadernode/ShaderNodeElements.js'; | ||
export const defaultShaderStages = [ 'fragment', 'vertex' ]; | ||
export const defaultBuildStages = [ 'construct', 'analyze', 'generate' ]; | ||
export const shaderStages = [ ...defaultShaderStages, 'compute' ]; | ||
@@ -66,6 +70,9 @@ export const vector = [ 'x', 'y', 'z', 'w' ]; | ||
keywords: new NodeKeywords(), | ||
material: object.material | ||
material: object.material, | ||
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => mul( levelNode, maxMipLevel( textureNode ) ) | ||
}; | ||
this.nodesData = new WeakMap(); | ||
this.cache = new NodeCache(); | ||
this.globalCache = this.cache; | ||
this.flowsData = new WeakMap(); | ||
@@ -168,2 +175,14 @@ | ||
setCache( cache ) { | ||
this.cache = cache; | ||
} | ||
getCache() { | ||
return this.cache; | ||
} | ||
isAvailable( /*name*/ ) { | ||
@@ -441,4 +460,6 @@ | ||
let nodeData = this.nodesData.get( node ); | ||
const cache = node.isGlobal( this ) ? this.globalCache : this.cache; | ||
let nodeData = cache.getNodeData( node ); | ||
if ( nodeData === undefined ) { | ||
@@ -448,3 +469,3 @@ | ||
this.nodesData.set( node, nodeData ); | ||
cache.setNodeData( node, nodeData ); | ||
@@ -459,9 +480,7 @@ } | ||
const nodeData = this.getDataFromNode( this, shaderStage ); | ||
const constructHash = node.getConstructHash( this ); | ||
const nodeData = this.getDataFromNode( node, shaderStage ); | ||
nodeData.properties = nodeData.properties || {}; | ||
nodeData.properties[ constructHash ] = nodeData.properties[ constructHash ] || { outputNode: null }; | ||
nodeData.properties ||= { outputNode: null }; | ||
return nodeData.properties[ constructHash ]; | ||
return nodeData.properties; | ||
@@ -713,62 +732,36 @@ } | ||
// stage 1: generate shader node | ||
// construct() -> stage 1: create possible new nodes and returns an output reference node | ||
// analyze() -> stage 2: analyze nodes to possible optimization and validation | ||
// generate() -> stage 3: generate shader | ||
this.setBuildStage( 'construct' ); | ||
for ( const buildStage of defaultBuildStages ) { | ||
for ( const shaderStage of shaderStages ) { | ||
this.setBuildStage( buildStage ); | ||
this.setShaderStage( shaderStage ); | ||
if ( this.context.vertex && this.context.vertex.isNode ) { | ||
const flowNodes = this.flowNodes[ shaderStage ]; | ||
this.flowNodeFromShaderStage( 'vertex', this.context.vertex ); | ||
for ( const node of flowNodes ) { | ||
node.build( this ); | ||
} | ||
} | ||
for ( const shaderStage of shaderStages ) { | ||
// stage 2: analyze nodes to possible optimization and validation | ||
this.setShaderStage( shaderStage ); | ||
this.setBuildStage( 'analyze' ); | ||
const flowNodes = this.flowNodes[ shaderStage ]; | ||
for ( const shaderStage of shaderStages ) { | ||
for ( const node of flowNodes ) { | ||
this.setShaderStage( shaderStage ); | ||
if ( buildStage === 'generate' ) { | ||
const flowNodes = this.flowNodes[ shaderStage ]; | ||
this.flowNode( node ); | ||
for ( const node of flowNodes ) { | ||
} else { | ||
node.build( this ); | ||
node.build( this ); | ||
} | ||
} | ||
} | ||
} | ||
// stage 3: pre-build vertex code used in fragment shader | ||
this.setBuildStage( 'generate' ); | ||
if ( this.context.vertex && this.context.vertex.isNode ) { | ||
this.flowNodeFromShaderStage( 'vertex', this.context.vertex ); | ||
} | ||
// stage 4: generate shader | ||
this.setBuildStage( 'generate' ); | ||
for ( const shaderStage of shaderStages ) { | ||
this.setShaderStage( shaderStage ); | ||
const flowNodes = this.flowNodes[ shaderStage ]; | ||
for ( const node of flowNodes ) { | ||
this.flowNode( node ); | ||
} | ||
@@ -781,3 +774,3 @@ | ||
// stage 5: build code for a specific output | ||
// stage 4: build code for a specific output | ||
@@ -784,0 +777,0 @@ this.buildCode(); |
@@ -13,2 +13,8 @@ import Node from './Node.js'; | ||
hasDependencies( builder ) { | ||
return builder.getDataFromNode( this ).dependenciesCount > 1; | ||
} | ||
build( builder, output ) { | ||
@@ -27,3 +33,3 @@ | ||
} else if ( builder.context.tempWrite !== false && type !== 'void ' && output !== 'void' && nodeData.dependenciesCount > 1 ) { | ||
} else if ( builder.context.tempWrite !== false && type !== 'void ' && output !== 'void' && this.hasDependencies( builder ) ) { | ||
@@ -30,0 +36,0 @@ const snippet = super.build( builder, type ); |
@@ -53,2 +53,8 @@ import Node from './Node.js'; | ||
isGlobal() { | ||
return true; | ||
} | ||
getHash( builder ) { | ||
@@ -55,0 +61,0 @@ |
@@ -15,2 +15,8 @@ import Node from './Node.js'; | ||
isGlobal() { | ||
return true; | ||
} | ||
getHash( builder ) { | ||
@@ -17,0 +23,0 @@ |
@@ -28,3 +28,3 @@ import TempNode from '../core/Node.js'; | ||
const colorNode = this.color || builder.context.color; | ||
const colorNode = this.colorNode || builder.context.color; | ||
@@ -42,3 +42,3 @@ const toneMapping = this.toneMapping; | ||
outputNode = this.colorNode; | ||
outputNode = colorNode; | ||
@@ -45,0 +45,0 @@ } |
@@ -17,8 +17,6 @@ import FogNode from './FogNode.js'; | ||
generate( builder ) { | ||
construct() { | ||
this.factorNode = smoothstep( this.nearNode, this.farNode, negate( positionView.z ) ); | ||
return super.generate( builder ); | ||
} | ||
@@ -25,0 +23,0 @@ |
import { | ||
ShaderNode, dotNV, vec2, vec4, add, mul, min, exp2 | ||
ShaderNode, dotNV, vec2, vec4, mul, min | ||
} from '../../shadernode/ShaderNodeElements.js'; | ||
@@ -17,7 +17,7 @@ | ||
const r = add( mul( roughness, c0 ), c1 ); | ||
const r = roughness.mul( c0 ).add( c1 ); | ||
const a004 = add( mul( min( mul( r.x, r.x ), exp2( mul( - 9.28, dotNV ) ) ), r.x ), r.y ); | ||
const a004 = min( mul( r.x, r.x ), dotNV.mul( -9.28 ).exp2() ).mul( r.x ).add( r.y ); | ||
const fab = add( mul( vec2( - 1.04, 1.04 ), a004 ), r.zw ); | ||
const fab = vec2( - 1.04, 1.04 ).mul( a004 ).add( r.zw ); | ||
@@ -24,0 +24,0 @@ return fab; |
@@ -1,2 +0,2 @@ | ||
import { ShaderNode, add, sub, mul, exp2 } from '../../shadernode/ShaderNodeBaseElements.js'; | ||
import { ShaderNode, sub } from '../../shadernode/ShaderNodeBaseElements.js'; | ||
@@ -12,5 +12,5 @@ const F_Schlick = new ShaderNode( ( inputs ) => { | ||
// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf | ||
const fresnel = exp2( mul( sub( mul( - 5.55473, dotVH ), 6.98316 ), dotVH ) ); | ||
const fresnel = dotVH.mul( - 5.55473 ).sub( 6.98316 ).mul( dotVH ).exp2(); | ||
return add( mul( f0, sub( 1.0, fresnel ) ), mul( f90, fresnel ) ); | ||
return f0.mul( sub( 1.0, fresnel ) ).add( f90.mul( fresnel ) ); | ||
@@ -17,0 +17,0 @@ } ); // validated |
import LightingNode from './LightingNode.js'; | ||
import ContextNode from '../core/ContextNode.js'; | ||
import MaxMipLevelNode from '../utils/MaxMipLevelNode.js'; | ||
import { ShaderNode, float, add, mul, div, log2, clamp, roughness, reflect, mix, positionViewDirection, negate, normalize, transformedNormalView, transformedNormalWorld, transformDirection, cameraViewMatrix } from '../shadernode/ShaderNodeElements.js'; | ||
import CacheNode from '../core/CacheNode.js'; | ||
import SpecularMIPLevelNode from '../utils/SpecularMIPLevelNode.js'; | ||
import { float, mul, roughness, positionViewDirection, transformedNormalView, transformedNormalWorld, cameraViewMatrix, equirectUV, vec2 } from '../shadernode/ShaderNodeElements.js'; | ||
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html | ||
const getSpecularMIPLevel = new ShaderNode( ( { texture, levelNode } ) => { | ||
const maxMIPLevelScalar = new MaxMipLevelNode( texture ); | ||
const sigma = div( mul( Math.PI, mul( levelNode, levelNode ) ), add( 1.0, levelNode ) ); | ||
const desiredMIPLevel = add( maxMIPLevelScalar, log2( sigma ) ); | ||
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar ); | ||
} ); | ||
class EnvironmentNode extends LightingNode { | ||
@@ -33,29 +22,103 @@ | ||
let reflectVec = reflect( negate( positionViewDirection ), transformedNormalView ); | ||
reflectVec = normalize( mix( reflectVec, transformedNormalView, mul( roughness, roughness ) ) ); | ||
reflectVec = transformDirection( reflectVec, cameraViewMatrix ); | ||
let reflectVec; | ||
let radianceTextureUVNode; | ||
let irradianceTextureUVNode; | ||
const radianceContext = new ContextNode( envNode, { | ||
tempRead: false, | ||
uvNode: reflectVec, | ||
levelNode: roughness, | ||
levelShaderNode: getSpecularMIPLevel | ||
getUVNode: ( textureNode ) => { | ||
let node = null; | ||
if ( reflectVec === undefined ) { | ||
reflectVec = positionViewDirection.negate().reflect( transformedNormalView ); | ||
reflectVec = reflectVec.mix( transformedNormalView, roughness.mul( roughness ) ).normalize(); | ||
reflectVec = reflectVec.transformDirection( cameraViewMatrix ); | ||
} | ||
if ( textureNode.isCubeTextureNode ) { | ||
node = reflectVec; | ||
} else if ( textureNode.isTextureNode ) { | ||
if ( radianceTextureUVNode === undefined ) { | ||
// @TODO: Needed PMREM | ||
radianceTextureUVNode = equirectUV( reflectVec ); | ||
radianceTextureUVNode = vec2( radianceTextureUVNode.x, radianceTextureUVNode.y.invert() ); | ||
} | ||
node = radianceTextureUVNode; | ||
} | ||
return node; | ||
}, | ||
getSamplerLevelNode: () => { | ||
return roughness; | ||
}, | ||
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => { | ||
return new SpecularMIPLevelNode( textureNode, levelNode ); | ||
} | ||
} ); | ||
const irradianceContext = new ContextNode( envNode, { | ||
tempRead: false, | ||
uvNode: transformedNormalWorld, | ||
levelNode: float( 1 ), | ||
levelShaderNode: getSpecularMIPLevel | ||
getUVNode: ( textureNode ) => { | ||
let node = null; | ||
if ( textureNode.isCubeTextureNode ) { | ||
node = transformedNormalWorld; | ||
} else if ( textureNode.isTextureNode ) { | ||
if ( irradianceTextureUVNode === undefined ) { | ||
// @TODO: Needed PMREM | ||
irradianceTextureUVNode = equirectUV( transformedNormalWorld ); | ||
irradianceTextureUVNode = vec2( irradianceTextureUVNode.x, irradianceTextureUVNode.y.invert() ); | ||
} | ||
node = irradianceTextureUVNode; | ||
} | ||
return node; | ||
}, | ||
getSamplerLevelNode: () => { | ||
return float( 1 ); | ||
}, | ||
getMIPLevelAlgorithmNode: ( textureNode, levelNode ) => { | ||
return new SpecularMIPLevelNode( textureNode, levelNode ); | ||
} | ||
} ); | ||
// it's used to cache the construct only if necessary: See `CubeTextureNode.getConstructReference()` | ||
radianceContext.context.environmentContext = radianceContext; | ||
irradianceContext.context.environmentContext = irradianceContext; | ||
// | ||
builder.context.radiance.add( radianceContext ); | ||
const isolateRadianceFlowContext = new CacheNode( radianceContext ); | ||
// | ||
builder.context.radiance.add( isolateRadianceFlowContext ); | ||
builder.context.iblIrradiance.add( mul( Math.PI, irradianceContext ) ); | ||
properties.radianceContext = radianceContext; | ||
properties.radianceContext = isolateRadianceFlowContext; | ||
properties.irradianceContext = irradianceContext; | ||
@@ -62,0 +125,0 @@ |
import Node from '../core/Node.js'; | ||
import LightingNode from './LightingNode.js'; | ||
import AnalyticLightNode from './AnalyticLightNode.js'; | ||
@@ -95,3 +95,3 @@ const references = new WeakMap(); | ||
const lightClass = light.constructor; | ||
const lightNodeClass = references.has( lightClass ) ? references.get( lightClass ) : LightingNode; | ||
const lightNodeClass = references.has( lightClass ) ? references.get( lightClass ) : AnalyticLightNode; | ||
@@ -98,0 +98,0 @@ lightNode = new lightNodeClass( light ); |
@@ -14,3 +14,3 @@ import NodeMaterial from './NodeMaterial.js'; | ||
this.lights = true; | ||
this.lights = false; | ||
@@ -17,0 +17,0 @@ this.colorNode = null; |
@@ -8,3 +8,3 @@ import { Material, ShaderMaterial } from 'three'; | ||
positionLocal, skinning, instance, modelViewProjection, lightingContext, colorSpace, | ||
materialAlphaTest, materialColor, materialOpacity | ||
materialAlphaTest, materialColor, materialOpacity, reference, rangeFog, exp2Fog | ||
} from '../shadernode/ShaderNodeElements.js'; | ||
@@ -144,4 +144,26 @@ | ||
if ( builder.fogNode ) outputNode = vec4( vec3( builder.fogNode.mix( outputNode ) ), outputNode.w ); | ||
let fogNode = builder.fogNode; | ||
if ( fogNode?.isNode !== true && builder.scene.fog ) { | ||
const fog = builder.scene.fog; | ||
if ( fog.isFogExp2 ) { | ||
fogNode = exp2Fog( reference( 'color', 'color', fog ), reference( 'density', 'float', fog ) ); | ||
} else if ( fog.isFog ) { | ||
fogNode = rangeFog( reference( 'color', 'color', fog ), reference( 'near', 'float', fog ), reference( 'far', 'float', fog ) ); | ||
} else { | ||
console.error( 'NodeMaterial: Unsupported fog configuration.', fog ); | ||
} | ||
} | ||
if ( fogNode ) outputNode = vec4( vec3( fogNode.mix( outputNode ) ), outputNode.w ); | ||
// RESULT | ||
@@ -148,0 +170,0 @@ |
@@ -30,2 +30,8 @@ import TempNode from '../core/TempNode.js'; | ||
hasDependencies( builder ) { | ||
return this.op !== '=' ? super.hasDependencies( builder ) : false; | ||
} | ||
getNodeType( builder, output ) { | ||
@@ -32,0 +38,0 @@ |
@@ -5,2 +5,3 @@ // core | ||
import BypassNode from './core/BypassNode.js'; | ||
import CacheNode from './core/CacheNode.js'; | ||
import CodeNode from './core/CodeNode.js'; | ||
@@ -16,2 +17,3 @@ import ConstNode from './core/ConstNode.js'; | ||
import NodeBuilder from './core/NodeBuilder.js'; | ||
import NodeCache from './core/NodeCache.js'; | ||
import NodeCode from './core/NodeCode.js'; | ||
@@ -25,2 +27,3 @@ import NodeFrame from './core/NodeFrame.js'; | ||
import PropertyNode from './core/PropertyNode.js'; | ||
import StackNode from './core/StackNode.js'; | ||
import TempNode from './core/TempNode.js'; | ||
@@ -75,3 +78,6 @@ import UniformNode from './core/UniformNode.js'; | ||
// lighting | ||
import PunctualLightNode from './lighting/PunctualLightNode.js'; | ||
import PointLightNode from './lighting/PointLightNode.js'; | ||
import DirectionalLightNode from './lighting/DirectionalLightNode.js'; | ||
import SpotLightNode from './lighting/SpotLightNode.js'; | ||
import AmbientLightNode from './lighting/AmbientLightNode.js'; | ||
import LightsNode from './lighting/LightsNode.js'; | ||
@@ -95,2 +101,3 @@ import LightingNode from './lighting/LightingNode.js'; | ||
import RotateUVNode from './utils/RotateUVNode.js'; | ||
import SpecularMIPLevelNode from './utils/SpecularMIPLevelNode.js'; | ||
import SplitNode from './utils/SplitNode.js'; | ||
@@ -116,2 +123,3 @@ import SpriteSheetUVNode from './utils/SpriteSheetUVNode.js'; | ||
import FogRangeNode from './fog/FogRangeNode.js'; | ||
import FogExp2Node from './fog/FogExp2Node.js'; | ||
@@ -138,2 +146,3 @@ // core | ||
BypassNode, | ||
CacheNode, | ||
CodeNode, | ||
@@ -149,2 +158,3 @@ ContextNode, | ||
NodeBuilder, | ||
NodeCache, | ||
NodeCode, | ||
@@ -158,2 +168,3 @@ NodeFrame, | ||
PropertyNode, | ||
StackNode, | ||
TempNode, | ||
@@ -208,3 +219,6 @@ UniformNode, | ||
// lighting | ||
PunctualLightNode, | ||
PointLightNode, | ||
DirectionalLightNode, | ||
SpotLightNode, | ||
AmbientLightNode, | ||
LightsNode, | ||
@@ -228,2 +242,3 @@ LightingNode, | ||
RotateUVNode, | ||
SpecularMIPLevelNode, | ||
SplitNode, | ||
@@ -240,2 +255,3 @@ SpriteSheetUVNode, | ||
FogRangeNode, | ||
FogExp2Node, | ||
@@ -264,2 +280,3 @@ // loaders | ||
BypassNode, | ||
CacheNode, | ||
CodeNode, | ||
@@ -275,2 +292,3 @@ ContextNode, | ||
NodeBuilder, | ||
NodeCache, | ||
NodeCode, | ||
@@ -284,2 +302,3 @@ NodeFrame, | ||
PropertyNode, | ||
StackNode, | ||
TempNode, | ||
@@ -334,3 +353,6 @@ UniformNode, | ||
// lighting | ||
PunctualLightNode, | ||
PointLightNode, | ||
DirectionalLightNode, | ||
SpotLightNode, | ||
AmbientLightNode, | ||
LightsNode, | ||
@@ -354,2 +376,3 @@ LightingNode, | ||
RotateUVNode, | ||
SpecularMIPLevelNode, | ||
SplitNode, | ||
@@ -366,2 +389,3 @@ SpriteSheetUVNode, | ||
FogRangeNode, | ||
FogExp2Node, | ||
@@ -368,0 +392,0 @@ // loaders |
@@ -7,4 +7,7 @@ import Node from '../core/Node.js'; | ||
import ConstNode from '../core/ConstNode.js'; | ||
import StackNode from '../core/StackNode.js'; | ||
import { getValueFromType } from '../core/NodeUtils.js'; | ||
import * as NodeElements from './ShaderNodeElements.js'; | ||
const shaderNodeHandler = { | ||
@@ -20,3 +23,3 @@ | ||
get: function ( node, prop ) { | ||
get: function ( node, prop, nodeObj ) { | ||
@@ -43,2 +46,8 @@ if ( typeof prop === 'string' && node[ prop ] === undefined ) { | ||
} else if ( NodeElements[ prop ] ) { | ||
const nodeElement = NodeElements[ prop ]; | ||
return ( ...params ) => nodeElement( nodeObj, ...params ); | ||
} | ||
@@ -172,14 +181,17 @@ | ||
generate( builder, output ) { | ||
getNodeType( builder ) { | ||
const nodeCall = this.call( {}, builder ); | ||
const { outputNode } = builder.getNodeProperties( this ); | ||
if ( nodeCall === undefined ) { | ||
return outputNode ? outputNode.getNodeType( builder ) : super.getNodeType( builder ); | ||
return ''; | ||
} | ||
} | ||
construct( builder ) { | ||
return builder.format( nodeCall.build( builder ), nodeCall.getNodeType( builder ), output ); | ||
const stackNode = new StackNode(); | ||
stackNode.outputNode = this.call( {}, stackNode, builder ); | ||
return stackNode; | ||
} | ||
@@ -186,0 +198,0 @@ |
@@ -5,2 +5,3 @@ // core | ||
import BypassNode from '../core/BypassNode.js'; | ||
import CacheNode from '../core/CacheNode.js'; | ||
import CodeNode from '../core/CodeNode.js'; | ||
@@ -26,2 +27,3 @@ import ContextNode from '../core/ContextNode.js'; | ||
import ModelNode from '../accessors/ModelNode.js'; | ||
import Object3DNode from '../accessors/Object3DNode.js'; | ||
import PointUVNode from '../accessors/PointUVNode.js'; | ||
@@ -50,2 +52,3 @@ import PositionNode from '../accessors/PositionNode.js'; | ||
import ConvertNode from '../utils/ConvertNode.js'; | ||
import MaxMipLevelNode from '../utils/MaxMipLevelNode.js'; | ||
@@ -123,4 +126,6 @@ // shader node utils | ||
export const convert = ( node, types ) => nodeObject( new ConvertNode( nodeObject( node ), types ) ); | ||
export const maxMipLevel = nodeProxy( MaxMipLevelNode ); | ||
export const bypass = nodeProxy( BypassNode ); | ||
export const cache = nodeProxy( CacheNode ); | ||
export const code = nodeProxy( CodeNode ); | ||
@@ -270,2 +275,8 @@ export const context = nodeProxy( ContextNode ); | ||
export const objectViewMatrix = nodeProxy( Object3DNode, Object3DNode.VIEW_MATRIX ); | ||
export const objectNormalMatrix = nodeProxy( Object3DNode, Object3DNode.NORMAL_MATRIX ); | ||
export const objectWorldMatrix = nodeProxy( Object3DNode, Object3DNode.WORLD_MATRIX ); | ||
export const objectPosition = nodeProxy( Object3DNode, Object3DNode.POSITION ); | ||
export const objectViewPosition = nodeProxy( Object3DNode, Object3DNode.VIEW_POSITION ); | ||
export const positionGeometry = nodeImmutable( PositionNode, PositionNode.GEOMETRY ); | ||
@@ -272,0 +283,0 @@ export const positionLocal = nodeImmutable( PositionNode, PositionNode.LOCAL ); |
@@ -24,6 +24,6 @@ // accessors | ||
import MatcapUVNode from '../utils/MatcapUVNode.js'; | ||
import MaxMipLevelNode from '../utils/MaxMipLevelNode.js'; | ||
import OscNode from '../utils/OscNode.js'; | ||
import RemapNode from '../utils/RemapNode.js'; | ||
import RotateUVNode from '../utils/RotateUVNode.js'; | ||
import SpecularMIPLevelNode from '../utils/SpecularMIPLevelNode.js'; | ||
import SpriteSheetUVNode from '../utils/SpriteSheetUVNode.js'; | ||
@@ -42,2 +42,3 @@ import TimerNode from '../utils/TimerNode.js'; | ||
import FogRangeNode from '../fog/FogRangeNode.js'; | ||
import FogExp2Node from '../fog/FogExp2Node.js'; | ||
@@ -117,3 +118,3 @@ // shader node utils | ||
export const maxMipLevel = nodeProxy( MaxMipLevelNode ); | ||
export const specularMIPLevel = nodeProxy( SpecularMIPLevelNode ); | ||
@@ -153,1 +154,2 @@ export const oscSine = nodeProxy( OscNode, OscNode.SINE ); | ||
export const rangeFog = nodeProxy( FogRangeNode ); | ||
export const exp2Fog = nodeProxy( FogExp2Node ); |
@@ -6,7 +6,7 @@ import UniformNode from '../core/UniformNode.js'; | ||
constructor( texture ) { | ||
constructor( textureNode ) { | ||
super( 0 ); | ||
this.texture = texture; | ||
this.textureNode = textureNode; | ||
@@ -17,6 +17,13 @@ this.updateType = NodeUpdateType.FRAME; | ||
get texture() { | ||
return this.textureNode.value; | ||
} | ||
update() { | ||
const images = this.texture.images; | ||
const image = ( images && images.length > 0 ) ? ( images[ 0 ]?.image || images[ 0 ] ) : this.texture.image; | ||
const texture = this.texture; | ||
const images = texture.images; | ||
const image = ( images && images.length > 0 ) ? ( images[ 0 ]?.image || images[ 0 ] ) : texture.image; | ||
@@ -23,0 +30,0 @@ if ( image?.width !== undefined ) { |
@@ -12,15 +12,5 @@ import { Mesh, IcosahedronGeometry, ShaderMaterial, DoubleSide } from 'three'; | ||
const isCubeMap = texture.isCubeTexture; | ||
const w = | ||
( isCubeMap ? texture.image[ 0 ]?.width : texture.image.width ) ?? 1024; | ||
const cubeSize = w / 4; | ||
const _lodMax = Math.floor( Math.log2( cubeSize ) ); | ||
const _cubeSize = Math.pow( 2, _lodMax ); | ||
const width = 3 * Math.max( _cubeSize, 16 * 7 ); | ||
const height = 4 * _cubeSize; | ||
const defines = [ | ||
isCubeMap ? '#define ENVMAP_TYPE_CUBE' : '', | ||
`#define CUBEUV_TEXEL_WIDTH ${1.0 / width}`, | ||
`#define CUBEUV_TEXEL_HEIGHT ${1.0 / height}`, | ||
`#define CUBEUV_MAX_MIP ${_lodMax}.0`, | ||
isCubeMap ? '#define ENVMAP_TYPE_CUBE' : '' | ||
]; | ||
@@ -42,3 +32,2 @@ | ||
const fragmentShader = defines.join( '\n' ) + /* glsl */ ` | ||
#define ENVMAP_TYPE_CUBE_UV | ||
@@ -119,3 +108,2 @@ varying vec3 vWorldPosition; | ||
#include <common> | ||
#include <cube_uv_reflection_fragment> | ||
@@ -122,0 +110,0 @@ void main() |
@@ -36,4 +36,2 @@ import { | ||
if ( CopyShader === undefined ) console.error( 'THREE.AdaptiveToneMappingPass relies on CopyShader' ); | ||
const copyShader = CopyShader; | ||
@@ -53,5 +51,2 @@ | ||
if ( LuminosityShader === undefined ) | ||
console.error( 'THREE.AdaptiveToneMappingPass relies on LuminosityShader' ); | ||
this.materialLuminance = new ShaderMaterial( { | ||
@@ -124,5 +119,2 @@ | ||
if ( ToneMapShader === undefined ) | ||
console.error( 'THREE.AdaptiveToneMappingPass relies on ToneMapShader' ); | ||
this.materialToneMap = new ShaderMaterial( { | ||
@@ -129,0 +121,0 @@ |
@@ -17,4 +17,2 @@ import { | ||
if ( AfterimageShader === undefined ) console.error( 'THREE.AfterimagePass relies on AfterimageShader' ); | ||
this.shader = AfterimageShader; | ||
@@ -21,0 +19,0 @@ |
@@ -42,4 +42,2 @@ import { | ||
if ( ConvolutionShader === undefined ) console.error( 'THREE.BloomPass relies on ConvolutionShader' ); | ||
const convolutionShader = ConvolutionShader; | ||
@@ -46,0 +44,0 @@ |
@@ -49,8 +49,2 @@ import { | ||
if ( BokehShader === undefined ) { | ||
console.error( 'THREE.BokehPass relies on BokehShader' ); | ||
} | ||
const bokehShader = BokehShader; | ||
@@ -57,0 +51,0 @@ const bokehUniforms = UniformsUtils.clone( bokehShader.uniforms ); |
@@ -14,4 +14,2 @@ import { | ||
if ( DotScreenShader === undefined ) console.error( 'THREE.DotScreenPass relies on DotScreenShader' ); | ||
const shader = DotScreenShader; | ||
@@ -18,0 +16,0 @@ |
import { | ||
BufferGeometry, | ||
Clock, | ||
Float32BufferAttribute, | ||
Mesh, | ||
OrthographicCamera, | ||
Vector2, | ||
@@ -50,16 +46,2 @@ WebGLRenderTarget | ||
// dependencies | ||
if ( CopyShader === undefined ) { | ||
console.error( 'THREE.EffectComposer relies on CopyShader' ); | ||
} | ||
if ( ShaderPass === undefined ) { | ||
console.error( 'THREE.EffectComposer relies on ShaderPass' ); | ||
} | ||
this.copyPass = new ShaderPass( CopyShader ); | ||
@@ -247,75 +229,2 @@ | ||
class Pass { | ||
constructor() { | ||
// if set to true, the pass is processed by the composer | ||
this.enabled = true; | ||
// if set to true, the pass indicates to swap read and write buffer after rendering | ||
this.needsSwap = true; | ||
// if set to true, the pass clears its buffer before rendering | ||
this.clear = false; | ||
// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer. | ||
this.renderToScreen = false; | ||
} | ||
setSize( /* width, height */ ) {} | ||
render( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) { | ||
console.error( 'THREE.Pass: .render() must be implemented in derived pass.' ); | ||
} | ||
} | ||
// Helper for passes that need to fill the viewport with a single quad. | ||
const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); | ||
// https://github.com/mrdoob/three.js/pull/21358 | ||
const _geometry = new BufferGeometry(); | ||
_geometry.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) ); | ||
_geometry.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) ); | ||
class FullScreenQuad { | ||
constructor( material ) { | ||
this._mesh = new Mesh( _geometry, material ); | ||
} | ||
dispose() { | ||
this._mesh.geometry.dispose(); | ||
} | ||
render( renderer ) { | ||
renderer.render( this._mesh, _camera ); | ||
} | ||
get material() { | ||
return this._mesh.material; | ||
} | ||
set material( value ) { | ||
this._mesh.material = value; | ||
} | ||
} | ||
export { EffectComposer, Pass, FullScreenQuad }; | ||
export { EffectComposer }; |
@@ -14,4 +14,2 @@ import { | ||
if ( FilmShader === undefined ) console.error( 'THREE.FilmPass relies on FilmShader' ); | ||
const shader = FilmShader; | ||
@@ -18,0 +16,0 @@ |
@@ -19,4 +19,2 @@ import { | ||
if ( DigitalGlitch === undefined ) console.error( 'THREE.GlitchPass relies on DigitalGlitch' ); | ||
const shader = DigitalGlitch; | ||
@@ -23,0 +21,0 @@ |
@@ -18,8 +18,2 @@ import { | ||
if ( HalftoneShader === undefined ) { | ||
console.error( 'THREE.HalftonePass requires HalftoneShader' ); | ||
} | ||
this.uniforms = UniformsUtils.clone( HalftoneShader.uniforms ); | ||
@@ -26,0 +20,0 @@ this.material = new ShaderMaterial( { |
@@ -94,3 +94,2 @@ import { | ||
// copy material | ||
if ( CopyShader === undefined ) console.error( 'THREE.OutlinePass relies on CopyShader' ); | ||
@@ -97,0 +96,0 @@ const copyShader = CopyShader; |
@@ -94,8 +94,2 @@ import { | ||
if ( SAOShader === undefined ) { | ||
console.error( 'THREE.SAOPass relies on SAOShader' ); | ||
} | ||
this.saoMaterial = new ShaderMaterial( { | ||
@@ -118,8 +112,2 @@ defines: Object.assign( {}, SAOShader.defines ), | ||
if ( DepthLimitedBlurShader === undefined ) { | ||
console.error( 'THREE.SAOPass relies on DepthLimitedBlurShader' ); | ||
} | ||
this.vBlurMaterial = new ShaderMaterial( { | ||
@@ -151,8 +139,2 @@ uniforms: UniformsUtils.clone( DepthLimitedBlurShader.uniforms ), | ||
if ( CopyShader === undefined ) { | ||
console.error( 'THREE.SAOPass relies on CopyShader' ); | ||
} | ||
this.materialCopy = new ShaderMaterial( { | ||
@@ -175,8 +157,2 @@ uniforms: UniformsUtils.clone( CopyShader.uniforms ), | ||
if ( UnpackDepthRGBAShader === undefined ) { | ||
console.error( 'THREE.SAOPass relies on UnpackDepthRGBAShader' ); | ||
} | ||
this.depthCopy = new ShaderMaterial( { | ||
@@ -183,0 +159,0 @@ uniforms: UniformsUtils.clone( UnpackDepthRGBAShader.uniforms ), |
@@ -15,4 +15,2 @@ import { | ||
if ( CopyShader === undefined ) console.error( 'THREE.SavePass relies on CopyShader' ); | ||
const shader = CopyShader; | ||
@@ -19,0 +17,0 @@ |
@@ -70,8 +70,2 @@ import { | ||
if ( SMAAEdgesShader === undefined ) { | ||
console.error( 'THREE.SMAAPass relies on SMAAShader' ); | ||
} | ||
this.uniformsEdges = UniformsUtils.clone( SMAAEdgesShader.uniforms ); | ||
@@ -78,0 +72,0 @@ |
import { | ||
AdditiveBlending, | ||
CustomBlending, | ||
OneFactor, | ||
AddEquation, | ||
SrcAlphaFactor, | ||
Color, | ||
@@ -38,4 +41,2 @@ ShaderMaterial, | ||
if ( CopyShader === undefined ) console.error( 'THREE.SSAARenderPass relies on CopyShader' ); | ||
const copyShader = CopyShader; | ||
@@ -49,5 +50,12 @@ this.copyUniforms = UniformsUtils.clone( copyShader.uniforms ); | ||
transparent: true, | ||
blending: AdditiveBlending, | ||
depthTest: false, | ||
depthWrite: false | ||
depthWrite: false, | ||
// do not use AdditiveBlending because it mixes the alpha channel instead of adding | ||
blending: CustomBlending, | ||
blendEquation: AddEquation, | ||
blendDst: OneFactor, | ||
blendDstAlpha: OneFactor, | ||
blendSrc: SrcAlphaFactor, | ||
blendSrcAlpha: OneFactor | ||
} ); | ||
@@ -54,0 +62,0 @@ |
@@ -86,8 +86,2 @@ import { | ||
if ( SSAOShader === undefined ) { | ||
console.error( 'THREE.SSAOPass: The pass relies on SSAOShader.' ); | ||
} | ||
this.ssaoMaterial = new ShaderMaterial( { | ||
@@ -381,8 +375,2 @@ defines: Object.assign( {}, SSAOShader.defines ), | ||
if ( SimplexNoise === undefined ) { | ||
console.error( 'THREE.SSAOPass: The pass relies on SimplexNoise.' ); | ||
} | ||
const simplex = new SimplexNoise(); | ||
@@ -389,0 +377,0 @@ |
@@ -205,8 +205,2 @@ import { | ||
if ( SSRShader === undefined ) { | ||
console.error( 'THREE.SSRPass: The pass relies on SSRShader.' ); | ||
} | ||
this.ssrMaterial = new ShaderMaterial( { | ||
@@ -213,0 +207,0 @@ defines: Object.assign( {}, SSRShader.defines, { |
@@ -14,4 +14,2 @@ import { | ||
if ( CopyShader === undefined ) console.error( 'THREE.TexturePass relies on CopyShader' ); | ||
const shader = CopyShader; | ||
@@ -18,0 +16,0 @@ |
@@ -73,5 +73,2 @@ import { | ||
if ( LuminosityHighPassShader === undefined ) | ||
console.error( 'THREE.UnrealBloomPass relies on LuminosityHighPassShader' ); | ||
const highPassShader = LuminosityHighPassShader; | ||
@@ -125,8 +122,3 @@ this.highPassUniforms = UniformsUtils.clone( highPassShader.uniforms ); | ||
// copy material | ||
if ( CopyShader === undefined ) { | ||
console.error( 'THREE.UnrealBloomPass relies on CopyShader' ); | ||
} | ||
const copyShader = CopyShader; | ||
@@ -133,0 +125,0 @@ |
@@ -30,2 +30,3 @@ import WebGPUUniformsGroup from '../WebGPUUniformsGroup.js'; | ||
bool: 'bool', | ||
color: 'vec3<f32>', | ||
@@ -32,0 +33,0 @@ vec2: 'vec2<f32>', |
@@ -85,3 +85,4 @@ import { GPULoadOp, GPUStoreOp } from './constants.js'; | ||
node = context( background, { | ||
uvNode: transformDirection( positionWorld, modelWorldMatrix ) | ||
// @TODO: Add Texture2D support using node context | ||
getUVNode: () => transformDirection( positionWorld, modelWorldMatrix ) | ||
} ); | ||
@@ -88,0 +89,0 @@ |
@@ -593,3 +593,3 @@ import { GPUIndexFormat, GPUTextureFormat, GPUStoreOp } from './constants.js'; | ||
this._background.clear(); | ||
this._background?.clear(); | ||
@@ -596,0 +596,0 @@ } |
@@ -93,3 +93,3 @@ import WebGPUUniformBuffer from './WebGPUUniformBuffer.js'; | ||
return offset; | ||
return Math.ceil( offset / GPUChunkSize ) * GPUChunkSize; | ||
@@ -96,0 +96,0 @@ } |
@@ -127,2 +127,4 @@ | ||
ShaderChunk.color_vertex, | ||
ShaderChunk.morphcolor_vertex, | ||
ShaderChunk.beginnormal_vertex, | ||
@@ -171,77 +173,4 @@ | ||
// Use the original MeshPhongMaterial's fragmentShader. | ||
this.fragmentShader = [ | ||
'#define PHONG', | ||
this.fragmentShader = ShaderLib.phong.fragmentShader; | ||
'uniform vec3 diffuse;', | ||
'uniform vec3 emissive;', | ||
'uniform vec3 specular;', | ||
'uniform float shininess;', | ||
'uniform float opacity;', | ||
ShaderChunk.common, | ||
ShaderChunk.packing, | ||
ShaderChunk.dithering_pars_fragment, | ||
ShaderChunk.color_pars_fragment, | ||
ShaderChunk.uv_pars_fragment, | ||
ShaderChunk.uv2_pars_fragment, | ||
ShaderChunk.map_pars_fragment, | ||
ShaderChunk.alphamap_pars_fragment, | ||
ShaderChunk.aomap_pars_fragment, | ||
ShaderChunk.lightmap_pars_fragment, | ||
ShaderChunk.emissivemap_pars_fragment, | ||
ShaderChunk.envmap_common_pars_fragment, | ||
ShaderChunk.envmap_pars_fragment, | ||
ShaderChunk.fog_pars_fragment, | ||
ShaderChunk.bsdfs, | ||
ShaderChunk.lights_pars_begin, | ||
ShaderChunk.normal_pars_fragment, | ||
ShaderChunk.lights_phong_pars_fragment, | ||
ShaderChunk.shadowmap_pars_fragment, | ||
ShaderChunk.bumpmap_pars_fragment, | ||
ShaderChunk.normalmap_pars_fragment, | ||
ShaderChunk.specularmap_pars_fragment, | ||
ShaderChunk.logdepthbuf_pars_fragment, | ||
ShaderChunk.clipping_planes_pars_fragment, | ||
'void main() {', | ||
ShaderChunk.clipping_planes_fragment, | ||
'vec4 diffuseColor = vec4( diffuse, opacity );', | ||
'ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );', | ||
'vec3 totalEmissiveRadiance = emissive;', | ||
ShaderChunk.logdepthbuf_fragment, | ||
ShaderChunk.map_fragment, | ||
ShaderChunk.color_fragment, | ||
ShaderChunk.alphamap_fragment, | ||
ShaderChunk.alphatest_fragment, | ||
ShaderChunk.specularmap_fragment, | ||
ShaderChunk.normal_fragment_begin, | ||
ShaderChunk.normal_fragment_maps, | ||
ShaderChunk.emissivemap_fragment, | ||
// accumulation | ||
ShaderChunk.lights_phong_fragment, | ||
ShaderChunk.lights_fragment_begin, | ||
ShaderChunk.lights_fragment_maps, | ||
ShaderChunk.lights_fragment_end, | ||
// modulation | ||
ShaderChunk.aomap_fragment, | ||
'vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;', | ||
ShaderChunk.envmap_fragment, | ||
'gl_FragColor = vec4( outgoingLight, diffuseColor.a );', | ||
ShaderChunk.tonemapping_fragment, | ||
ShaderChunk.encodings_fragment, | ||
ShaderChunk.fog_fragment, | ||
ShaderChunk.premultiplied_alpha_fragment, | ||
ShaderChunk.dithering_fragment, | ||
'}', | ||
].join( '\n' ); | ||
this.setValues( parameters ); | ||
@@ -248,0 +177,0 @@ |
@@ -146,10 +146,14 @@ import { | ||
vertex.fromBufferAttribute( position, i ); | ||
if ( child.isMesh ) { | ||
if ( child.isSkinnedMesh ) { | ||
child.getVertexPosition( i, vertex ); | ||
child.boneTransform( i, vertex ); | ||
} else { | ||
vertex.fromBufferAttribute( position, i ); | ||
} | ||
if ( ! child.isSkinnedMesh ) { | ||
vertex.applyMatrix4( child.matrixWorld ); | ||
@@ -156,0 +160,0 @@ |
{ | ||
"name": "three", | ||
"version": "0.147.0", | ||
"version": "0.148.0", | ||
"description": "JavaScript 3D library", | ||
@@ -109,6 +109,5 @@ "type": "module", | ||
"build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule", | ||
"build-examples": "rollup -c utils/build/rollup.examples.config.js && echo '\nFormatting...' && eslint examples/js --ext js --ignore-pattern libs --ignore-pattern ifc --fix", | ||
"dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"", | ||
"lint": "eslint src --ext js", | ||
"lint-examples": "eslint examples/js examples/jsm examples/*.html --ext js,html --ignore-pattern libs --ignore-pattern ifc", | ||
"lint-examples": "eslint examples/jsm examples/*.html --ext js,html --ignore-pattern libs --ignore-pattern ifc", | ||
"lint-docs": "eslint docs --ext html", | ||
@@ -145,11 +144,11 @@ "lint-fix": "npm run lint -- --fix && npm run lint-examples -- --fix && npm run lint-docs -- --fix", | ||
"devDependencies": { | ||
"@babel/core": "^7.19.3", | ||
"@babel/core": "^7.20.5", | ||
"@babel/eslint-parser": "^7.19.1", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/preset-env": "^7.19.3", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-node-resolve": "^14.1.0", | ||
"chalk": "^5.0.1", | ||
"concurrently": "^7.4.0", | ||
"eslint": "^8.24.0", | ||
"@babel/preset-env": "^7.20.2", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"chalk": "^5.1.2", | ||
"concurrently": "^7.6.0", | ||
"eslint": "^8.28.0", | ||
"eslint-config-mdcs": "^5.0.0", | ||
@@ -162,3 +161,3 @@ "eslint-plugin-compat": "^4.0.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-visualizer": "^5.8.2", | ||
"rollup-plugin-visualizer": "^5.8.3", | ||
"servez": "^1.14.1" | ||
@@ -165,0 +164,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
export const REVISION = '147'; | ||
export const REVISION = '148'; | ||
export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }; | ||
@@ -15,2 +15,3 @@ export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }; | ||
export const DoubleSide = 2; | ||
export const TwoPassDoubleSide = 3; | ||
export const NoBlending = 0; | ||
@@ -17,0 +18,0 @@ export const NormalBlending = 1; |
@@ -11,3 +11,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
constructor( array, itemSize, normalized ) { | ||
constructor( array, itemSize, normalized = false ) { | ||
@@ -27,3 +27,3 @@ if ( Array.isArray( array ) ) { | ||
this.count = array !== undefined ? array.length / itemSize : 0; | ||
this.normalized = normalized === true; | ||
this.normalized = normalized; | ||
@@ -30,0 +30,0 @@ this.usage = StaticDrawUsage; |
@@ -971,3 +971,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
return new this.constructor().copy( this ); | ||
return new this.constructor().copy( this ); | ||
@@ -974,0 +974,0 @@ } |
@@ -19,3 +19,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
this.normalized = normalized === true; | ||
this.normalized = normalized; | ||
@@ -22,0 +22,0 @@ } |
@@ -250,2 +250,4 @@ import { Quaternion } from '../math/Quaternion.js'; | ||
this.updateWorldMatrix( true, false ); | ||
return vector.applyMatrix4( this.matrixWorld ); | ||
@@ -257,2 +259,4 @@ | ||
this.updateWorldMatrix( true, false ); | ||
return vector.applyMatrix4( _m1.copy( this.matrixWorld ).invert() ); | ||
@@ -471,2 +475,24 @@ | ||
getObjectsByProperty( name, value ) { | ||
let result = []; | ||
if ( this[ name ] === value ) result.push( this ); | ||
for ( let i = 0, l = this.children.length; i < l; i ++ ) { | ||
const childResult = this.children[ i ].getObjectsByProperty( name, value ); | ||
if ( childResult.length > 0 ) { | ||
result = result.concat( childResult ); | ||
} | ||
} | ||
return result; | ||
} | ||
getWorldPosition( target ) { | ||
@@ -693,3 +719,3 @@ | ||
if ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder; | ||
if ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData; | ||
if ( Object.keys( this.userData ).length > 0 ) object.userData = this.userData; | ||
@@ -696,0 +722,0 @@ object.layers = this.layers.mask; |
@@ -8,3 +8,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
constructor( radius = 1, segments = 8, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
constructor( radius = 1, segments = 32, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
@@ -11,0 +11,0 @@ super(); |
@@ -5,3 +5,3 @@ import { CylinderGeometry } from './CylinderGeometry.js'; | ||
constructor( radius = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
constructor( radius = 1, height = 1, radialSegments = 32, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
@@ -8,0 +8,0 @@ super( 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ); |
@@ -8,3 +8,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
constructor( radiusTop = 1, radiusBottom = 1, height = 1, radialSegments = 8, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
constructor( radiusTop = 1, radiusBottom = 1, height = 1, radialSegments = 32, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
@@ -11,0 +11,0 @@ super(); |
@@ -8,3 +8,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
constructor( innerRadius = 0.5, outerRadius = 1, thetaSegments = 8, phiSegments = 1, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
constructor( innerRadius = 0.5, outerRadius = 1, thetaSegments = 32, phiSegments = 1, thetaStart = 0, thetaLength = Math.PI * 2 ) { | ||
@@ -11,0 +11,0 @@ super(); |
@@ -7,3 +7,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
constructor( radius = 1, tube = 0.4, radialSegments = 8, tubularSegments = 6, arc = Math.PI * 2 ) { | ||
constructor( radius = 1, tube = 0.4, radialSegments = 12, tubularSegments = 48, arc = Math.PI * 2 ) { | ||
@@ -10,0 +10,0 @@ super(); |
@@ -664,2 +664,3 @@ import { | ||
if ( data.generateMipmaps !== undefined ) texture.generateMipmaps = data.generateMipmaps; | ||
if ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha; | ||
@@ -666,0 +667,0 @@ if ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment; |
@@ -362,3 +362,3 @@ import { EventDispatcher } from '../core/EventDispatcher.js'; | ||
if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData; | ||
if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData; | ||
@@ -365,0 +365,0 @@ // TODO: Copied from Object3D.toJSON |
@@ -8,3 +8,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
import { Triangle } from '../math/Triangle.js'; | ||
import { DoubleSide, BackSide } from '../constants.js'; | ||
import { BackSide, FrontSide } from '../constants.js'; | ||
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; | ||
@@ -22,8 +22,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
const _tempA = /*@__PURE__*/ new Vector3(); | ||
const _tempB = /*@__PURE__*/ new Vector3(); | ||
const _tempC = /*@__PURE__*/ new Vector3(); | ||
const _morphA = /*@__PURE__*/ new Vector3(); | ||
const _morphB = /*@__PURE__*/ new Vector3(); | ||
const _morphC = /*@__PURE__*/ new Vector3(); | ||
@@ -108,2 +103,52 @@ const _uvA = /*@__PURE__*/ new Vector2(); | ||
getVertexPosition( vert, target ) { | ||
const geometry = this.geometry; | ||
const position = geometry.attributes.position; | ||
const morphPosition = geometry.morphAttributes.position; | ||
const morphTargetsRelative = geometry.morphTargetsRelative; | ||
target.fromBufferAttribute( position, vert ); | ||
const morphInfluences = this.morphTargetInfluences; | ||
if ( morphPosition && morphInfluences ) { | ||
_morphA.set( 0, 0, 0 ); | ||
for ( let i = 0, il = morphPosition.length; i < il; i ++ ) { | ||
const influence = morphInfluences[ i ]; | ||
const morphAttribute = morphPosition[ i ]; | ||
if ( influence === 0 ) continue; | ||
_tempA.fromBufferAttribute( morphAttribute, vert ); | ||
if ( morphTargetsRelative ) { | ||
_morphA.addScaledVector( _tempA, influence ); | ||
} else { | ||
_morphA.addScaledVector( _tempA.sub( target ), influence ); | ||
} | ||
} | ||
target.add( _morphA ); | ||
} | ||
if ( this.isSkinnedMesh ) { | ||
this.boneTransform( vert, target ); | ||
} | ||
return target; | ||
} | ||
raycast( raycaster, intersects ) { | ||
@@ -143,4 +188,2 @@ | ||
const position = geometry.attributes.position; | ||
const morphPosition = geometry.morphAttributes.position; | ||
const morphTargetsRelative = geometry.morphTargetsRelative; | ||
const uv = geometry.attributes.uv; | ||
@@ -171,3 +214,3 @@ const uv2 = geometry.attributes.uv2; | ||
intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); | ||
intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, uv, uv2, a, b, c ); | ||
@@ -197,3 +240,3 @@ if ( intersection ) { | ||
intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); | ||
intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, uv, uv2, a, b, c ); | ||
@@ -231,3 +274,3 @@ if ( intersection ) { | ||
intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); | ||
intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, uv, uv2, a, b, c ); | ||
@@ -257,3 +300,3 @@ if ( intersection ) { | ||
intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ); | ||
intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, uv, uv2, a, b, c ); | ||
@@ -287,3 +330,3 @@ if ( intersection ) { | ||
intersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point ); | ||
intersect = ray.intersectTriangle( pA, pB, pC, ( material.side === FrontSide ), point ); | ||
@@ -309,57 +352,8 @@ } | ||
function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) { | ||
function checkBufferGeometryIntersection( object, material, raycaster, ray, uv, uv2, a, b, c ) { | ||
_vA.fromBufferAttribute( position, a ); | ||
_vB.fromBufferAttribute( position, b ); | ||
_vC.fromBufferAttribute( position, c ); | ||
object.getVertexPosition( a, _vA ); | ||
object.getVertexPosition( b, _vB ); | ||
object.getVertexPosition( c, _vC ); | ||
const morphInfluences = object.morphTargetInfluences; | ||
if ( morphPosition && morphInfluences ) { | ||
_morphA.set( 0, 0, 0 ); | ||
_morphB.set( 0, 0, 0 ); | ||
_morphC.set( 0, 0, 0 ); | ||
for ( let i = 0, il = morphPosition.length; i < il; i ++ ) { | ||
const influence = morphInfluences[ i ]; | ||
const morphAttribute = morphPosition[ i ]; | ||
if ( influence === 0 ) continue; | ||
_tempA.fromBufferAttribute( morphAttribute, a ); | ||
_tempB.fromBufferAttribute( morphAttribute, b ); | ||
_tempC.fromBufferAttribute( morphAttribute, c ); | ||
if ( morphTargetsRelative ) { | ||
_morphA.addScaledVector( _tempA, influence ); | ||
_morphB.addScaledVector( _tempB, influence ); | ||
_morphC.addScaledVector( _tempC, influence ); | ||
} else { | ||
_morphA.addScaledVector( _tempA.sub( _vA ), influence ); | ||
_morphB.addScaledVector( _tempB.sub( _vB ), influence ); | ||
_morphC.addScaledVector( _tempC.sub( _vC ), influence ); | ||
} | ||
} | ||
_vA.add( _morphA ); | ||
_vB.add( _morphB ); | ||
_vC.add( _morphC ); | ||
} | ||
if ( object.isSkinnedMesh ) { | ||
object.boneTransform( a, _vA ); | ||
object.boneTransform( b, _vB ); | ||
object.boneTransform( c, _vC ); | ||
} | ||
const intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint ); | ||
@@ -366,0 +360,0 @@ |
@@ -88,3 +88,3 @@ export default /* glsl */` | ||
vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; | ||
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; // #25071 | ||
@@ -91,0 +91,0 @@ if ( face > 2.0 ) { |
@@ -71,3 +71,3 @@ export default /* glsl */` | ||
pointLightShadow = pointLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; | ||
#endif | ||
@@ -120,3 +120,3 @@ | ||
spotLightShadow = spotLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; | ||
#endif | ||
@@ -147,3 +147,3 @@ | ||
directionalLightShadow = directionalLightShadows[ i ]; | ||
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; | ||
#endif | ||
@@ -150,0 +150,0 @@ |
@@ -113,12 +113,5 @@ export default /* glsl */` | ||
// if ( something && something ) breaks ATI OpenGL shader compiler | ||
// if ( all( something, something ) ) using this instead | ||
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; | ||
bool frustumTest = inFrustum && shadowCoord.z <= 1.0; | ||
bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 ); | ||
bool inFrustum = all( inFrustumVec ); | ||
bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 ); | ||
bool frustumTest = all( frustumTestVec ); | ||
if ( frustumTest ) { | ||
@@ -125,0 +118,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js'; | ||
import { BackSide, FrontSide, CubeUVReflectionMapping, sRGBEncoding } from '../../constants.js'; | ||
import { BoxGeometry } from '../../geometries/BoxGeometry.js'; | ||
@@ -111,2 +111,3 @@ import { PlaneGeometry } from '../../geometries/PlaneGeometry.js'; | ||
boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity; | ||
boxMesh.material.toneMapped = ( background.encoding === sRGBEncoding ) ? false : true; | ||
@@ -167,2 +168,3 @@ if ( currentBackground !== background || | ||
planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity; | ||
planeMesh.material.toneMapped = ( background.encoding === sRGBEncoding ) ? false : true; | ||
@@ -169,0 +171,0 @@ if ( background.matrixAutoUpdate === true ) { |
@@ -243,34 +243,34 @@ import { FrontSide, BackSide, DoubleSide, NearestFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js'; | ||
} | ||
if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) || | ||
( material.displacementMap && material.displacementScale !== 0 ) || | ||
( material.alphaMap && material.alphaTest > 0 ) || | ||
( material.map && material.alphaTest > 0 ) ) { | ||
if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) || | ||
( material.displacementMap && material.displacementScale !== 0 ) || | ||
( material.alphaMap && material.alphaTest > 0 ) || | ||
( material.map && material.alphaTest > 0 ) ) { | ||
// in this case we need a unique material instance reflecting the | ||
// appropriate state | ||
// in this case we need a unique material instance reflecting the | ||
// appropriate state | ||
const keyA = result.uuid, keyB = material.uuid; | ||
const keyA = result.uuid, keyB = material.uuid; | ||
let materialsForVariant = _materialCache[ keyA ]; | ||
let materialsForVariant = _materialCache[ keyA ]; | ||
if ( materialsForVariant === undefined ) { | ||
if ( materialsForVariant === undefined ) { | ||
materialsForVariant = {}; | ||
_materialCache[ keyA ] = materialsForVariant; | ||
materialsForVariant = {}; | ||
_materialCache[ keyA ] = materialsForVariant; | ||
} | ||
} | ||
let cachedMaterial = materialsForVariant[ keyB ]; | ||
let cachedMaterial = materialsForVariant[ keyB ]; | ||
if ( cachedMaterial === undefined ) { | ||
if ( cachedMaterial === undefined ) { | ||
cachedMaterial = result.clone(); | ||
materialsForVariant[ keyB ] = cachedMaterial; | ||
cachedMaterial = result.clone(); | ||
materialsForVariant[ keyB ] = cachedMaterial; | ||
} | ||
result = cachedMaterial; | ||
} | ||
result = cachedMaterial; | ||
} | ||
@@ -277,0 +277,0 @@ |
@@ -310,3 +310,3 @@ import { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js'; | ||
const uboBindings = new WeakMap(); | ||
const uboProgamMap = new WeakMap(); | ||
const uboProgramMap = new WeakMap(); | ||
@@ -1108,3 +1108,3 @@ let enabledCapabilities = {}; | ||
let mapping = uboProgamMap.get( program ); | ||
let mapping = uboProgramMap.get( program ); | ||
@@ -1115,3 +1115,3 @@ if ( mapping === undefined ) { | ||
uboProgamMap.set( program, mapping ); | ||
uboProgramMap.set( program, mapping ); | ||
@@ -1134,12 +1134,11 @@ } | ||
const mapping = uboProgamMap.get( program ); | ||
const mapping = uboProgramMap.get( program ); | ||
const blockIndex = mapping.get( uniformsGroup ); | ||
if ( uboBindings.get( uniformsGroup ) !== blockIndex ) { | ||
if ( uboBindings.get( program ) !== blockIndex ) { | ||
// bind shader specific block index to global block point | ||
gl.uniformBlockBinding( program, blockIndex, uniformsGroup.__bindingPointIndex ); | ||
uboBindings.set( uniformsGroup, blockIndex ); | ||
uboBindings.set( program, blockIndex ); | ||
@@ -1146,0 +1145,0 @@ } |
@@ -577,2 +577,4 @@ import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, sRGBEncoding, LinearEncoding, UnsignedByteType, _SRGBAFormat } from '../../constants.js'; | ||
if ( texture.magFilter === NearestFilter ) return; | ||
if ( texture.minFilter !== NearestMipmapLinearFilter && texture.minFilter !== LinearMipmapLinearFilter ) return; | ||
if ( texture.type === FloatType && extensions.has( 'OES_texture_float_linear' ) === false ) return; // verify extension for WebGL 1 and WebGL 2 | ||
@@ -579,0 +581,0 @@ if ( isWebGL2 === false && ( texture.type === HalfFloatType && extensions.has( 'OES_texture_half_float_linear' ) === false ) ) return; // verify extension for WebGL 1 only |
@@ -105,39 +105,48 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) { | ||
const value = uniform.value; | ||
const offset = uniform.__offset; | ||
if ( typeof value === 'number' ) { | ||
const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ]; | ||
uniform.__data[ 0 ] = value; | ||
gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data ); | ||
let arrayOffset = 0; | ||
} else { | ||
for ( let i = 0; i < values.length; i ++ ) { | ||
if ( uniform.value.isMatrix3 ) { | ||
const value = values[ i ]; | ||
const info = getUniformSize( value ); | ||
if ( typeof value === 'number' ) { | ||
uniform.__data[ 0 ] = value; | ||
gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data ); | ||
} else if ( value.isMatrix3 ) { | ||
// manually converting 3x3 to 3x4 | ||
uniform.__data[ 0 ] = uniform.value.elements[ 0 ]; | ||
uniform.__data[ 1 ] = uniform.value.elements[ 1 ]; | ||
uniform.__data[ 2 ] = uniform.value.elements[ 2 ]; | ||
uniform.__data[ 3 ] = uniform.value.elements[ 0 ]; | ||
uniform.__data[ 4 ] = uniform.value.elements[ 3 ]; | ||
uniform.__data[ 5 ] = uniform.value.elements[ 4 ]; | ||
uniform.__data[ 6 ] = uniform.value.elements[ 5 ]; | ||
uniform.__data[ 7 ] = uniform.value.elements[ 0 ]; | ||
uniform.__data[ 8 ] = uniform.value.elements[ 6 ]; | ||
uniform.__data[ 9 ] = uniform.value.elements[ 7 ]; | ||
uniform.__data[ 10 ] = uniform.value.elements[ 8 ]; | ||
uniform.__data[ 11 ] = uniform.value.elements[ 0 ]; | ||
uniform.__data[ 0 ] = value.elements[ 0 ]; | ||
uniform.__data[ 1 ] = value.elements[ 1 ]; | ||
uniform.__data[ 2 ] = value.elements[ 2 ]; | ||
uniform.__data[ 3 ] = value.elements[ 0 ]; | ||
uniform.__data[ 4 ] = value.elements[ 3 ]; | ||
uniform.__data[ 5 ] = value.elements[ 4 ]; | ||
uniform.__data[ 6 ] = value.elements[ 5 ]; | ||
uniform.__data[ 7 ] = value.elements[ 0 ]; | ||
uniform.__data[ 8 ] = value.elements[ 6 ]; | ||
uniform.__data[ 9 ] = value.elements[ 7 ]; | ||
uniform.__data[ 10 ] = value.elements[ 8 ]; | ||
uniform.__data[ 11 ] = value.elements[ 0 ]; | ||
} else { | ||
value.toArray( uniform.__data ); | ||
value.toArray( uniform.__data, arrayOffset ); | ||
arrayOffset += info.storage / Float32Array.BYTES_PER_ELEMENT; | ||
} | ||
gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data ); | ||
} | ||
gl.bufferSubData( gl.UNIFORM_BUFFER, offset, uniform.__data ); | ||
} | ||
@@ -165,4 +174,14 @@ | ||
cache[ index ] = value.clone(); | ||
const values = Array.isArray( value ) ? value : [ value ]; | ||
const tempValues = []; | ||
for ( let i = 0; i < values.length; i ++ ) { | ||
tempValues.push( values[ i ].clone() ); | ||
} | ||
cache[ index ] = tempValues; | ||
} | ||
@@ -187,9 +206,16 @@ | ||
const cachedObject = cache[ index ]; | ||
const cachedObjects = Array.isArray( cache[ index ] ) ? cache[ index ] : [ cache[ index ] ]; | ||
const values = Array.isArray( value ) ? value : [ value ]; | ||
if ( cachedObject.equals( value ) === false ) { | ||
for ( let i = 0; i < cachedObjects.length; i ++ ) { | ||
cachedObject.copy( value ); | ||
return true; | ||
const cachedObject = cachedObjects[ i ]; | ||
if ( cachedObject.equals( values[ i ] ) === false ) { | ||
cachedObject.copy( values[ i ] ); | ||
return true; | ||
} | ||
} | ||
@@ -219,7 +245,24 @@ | ||
const uniform = uniforms[ i ]; | ||
const info = getUniformSize( uniform ); | ||
const infos = { | ||
boundary: 0, // bytes | ||
storage: 0 // bytes | ||
}; | ||
const values = Array.isArray( uniform.value ) ? uniform.value : [ uniform.value ]; | ||
for ( let j = 0, jl = values.length; j < jl; j ++ ) { | ||
const value = values[ j ]; | ||
const info = getUniformSize( value ); | ||
infos.boundary += info.boundary; | ||
infos.storage += info.storage; | ||
} | ||
// the following two properties will be used for partial buffer updates | ||
uniform.__data = new Float32Array( info.storage / Float32Array.BYTES_PER_ELEMENT ); | ||
uniform.__data = new Float32Array( infos.storage / Float32Array.BYTES_PER_ELEMENT ); | ||
uniform.__offset = offset; | ||
@@ -237,3 +280,3 @@ | ||
if ( chunkOffset !== 0 && ( remainingSizeInChunk - info.boundary ) < 0 ) { | ||
if ( chunkOffset !== 0 && ( remainingSizeInChunk - infos.boundary ) < 0 ) { | ||
@@ -249,3 +292,3 @@ // add padding and adjust offset | ||
offset += info.storage; | ||
offset += infos.storage; | ||
@@ -269,6 +312,4 @@ } | ||
function getUniformSize( uniform ) { | ||
function getUniformSize( value ) { | ||
const value = uniform.value; | ||
const info = { | ||
@@ -275,0 +316,0 @@ boundary: 0, // bytes |
import { | ||
REVISION, | ||
BackSide, | ||
DoubleSide, | ||
TwoPassDoubleSide, | ||
FrontSide, | ||
@@ -831,3 +831,3 @@ RGBAFormat, | ||
if ( material.transparent === true && material.side === DoubleSide ) { | ||
if ( material.transparent === true && material.side === TwoPassDoubleSide ) { | ||
@@ -842,3 +842,3 @@ material.side = BackSide; | ||
material.side = DoubleSide; | ||
material.side = TwoPassDoubleSide; | ||
@@ -1315,3 +1315,3 @@ } else { | ||
if ( material.transparent === true && material.side === DoubleSide ) { | ||
if ( material.transparent === true && material.side === TwoPassDoubleSide ) { | ||
@@ -1326,3 +1326,3 @@ material.side = BackSide; | ||
material.side = DoubleSide; | ||
material.side = TwoPassDoubleSide; | ||
@@ -1329,0 +1329,0 @@ } else { |
@@ -189,2 +189,3 @@ import { EventDispatcher } from '../core/EventDispatcher.js'; | ||
generateMipmaps: this.generateMipmaps, | ||
premultiplyAlpha: this.premultiplyAlpha, | ||
@@ -195,3 +196,3 @@ unpackAlignment: this.unpackAlignment | ||
if ( JSON.stringify( this.userData ) !== '{}' ) output.userData = this.userData; | ||
if ( Object.keys( this.userData ).length > 0 ) output.userData = this.userData; | ||
@@ -198,0 +199,0 @@ if ( ! isRootObject ) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
10
25
30026473
924
362610