three
Advanced tools
Comparing version 0.142.0 to 0.143.0
@@ -847,4 +847,2 @@ ( function () { | ||
if ( scope.enabled === false ) return; | ||
switch ( state ) { | ||
@@ -851,0 +849,0 @@ |
@@ -963,4 +963,2 @@ import { | ||
if ( scope.enabled === false ) return; | ||
switch ( state ) { | ||
@@ -967,0 +965,0 @@ |
@@ -566,3 +566,3 @@ import { | ||
// Detatch from object | ||
// Detach from object | ||
detach() { | ||
@@ -1320,8 +1320,8 @@ | ||
const AXIS_HIDE_TRESHOLD = 0.99; | ||
const PLANE_HIDE_TRESHOLD = 0.2; | ||
const AXIS_HIDE_THRESHOLD = 0.99; | ||
const PLANE_HIDE_THRESHOLD = 0.2; | ||
if ( handle.name === 'X' ) { | ||
if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) { | ||
@@ -1337,3 +1337,3 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); | ||
if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) { | ||
@@ -1349,3 +1349,3 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); | ||
if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) > AXIS_HIDE_THRESHOLD ) { | ||
@@ -1361,3 +1361,3 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); | ||
if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitZ ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) { | ||
@@ -1373,3 +1373,3 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); | ||
if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitX ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) { | ||
@@ -1385,3 +1385,3 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); | ||
if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_TRESHOLD ) { | ||
if ( Math.abs( _alignVector.copy( _unitY ).applyQuaternion( quaternion ).dot( this.eye ) ) < PLANE_HIDE_THRESHOLD ) { | ||
@@ -1388,0 +1388,0 @@ handle.scale.set( 1e-10, 1e-10, 1e-10 ); |
@@ -0,1 +1,5 @@ | ||
import { | ||
DoubleSide | ||
} from 'three'; | ||
import * as fflate from '../libs/fflate.module.js'; | ||
@@ -411,3 +415,3 @@ | ||
if ( material.side === THREE.DoubleSide ) { | ||
if ( material.side === DoubleSide ) { | ||
@@ -414,0 +418,0 @@ console.warn( 'THREE.USDZExporter: USDZ does not support double sided materials', material ); |
@@ -20,3 +20,3 @@ import { | ||
console.error( 'THREE.ConvexBufferGeometry: ConvexBufferGeometry relies on ConvexHull' ); | ||
console.error( 'THREE.ConvexGeometry: ConvexGeometry relies on ConvexHull' ); | ||
@@ -23,0 +23,0 @@ } |
@@ -1,4 +0,2 @@ | ||
import { | ||
Vector2 | ||
} from 'three'; | ||
import { Vector2 } from 'three'; | ||
@@ -61,2 +59,4 @@ class SelectionHelper { | ||
this.element.style.display = 'none'; | ||
this.renderer.domElement.parentElement.appendChild( this.element ); | ||
@@ -76,2 +76,4 @@ | ||
this.element.style.display = 'block'; | ||
this.pointBottomRight.x = Math.max( this.startPoint.x, event.clientX ); | ||
@@ -78,0 +80,0 @@ this.pointBottomRight.y = Math.max( this.startPoint.y, event.clientY ); |
@@ -5,2 +5,3 @@ import { | ||
Float32BufferAttribute, | ||
Int32BufferAttribute, | ||
Loader, | ||
@@ -233,2 +234,4 @@ LoaderUtils, | ||
const color = []; | ||
const intensity = []; | ||
const label = []; | ||
@@ -290,2 +293,14 @@ // ascii | ||
if ( offset.intensity !== undefined ) { | ||
intensity.push( parseFloat( line[ offset.intensity ] ) ); | ||
} | ||
if ( offset.label !== undefined ) { | ||
label.push( parseInt( line[ offset.label ] ) ); | ||
} | ||
} | ||
@@ -344,2 +359,16 @@ | ||
if ( offset.intensity !== undefined ) { | ||
const intensityIndex = PCDheader.fields.indexOf( 'intensity' ); | ||
intensity.push( dataview.getFloat32( ( PCDheader.points * offset.intensity ) + PCDheader.size[ intensityIndex ] * i, this.littleEndian ) ); | ||
} | ||
if ( offset.label !== undefined ) { | ||
const labelIndex = PCDheader.fields.indexOf( 'label' ); | ||
label.push( dataview.getInt32( ( PCDheader.points * offset.label ) + PCDheader.size[ labelIndex ] * i, this.littleEndian ) ); | ||
} | ||
} | ||
@@ -382,2 +411,14 @@ | ||
if ( offset.intensity !== undefined ) { | ||
intensity.push( dataview.getFloat32( row + offset.intensity, this.littleEndian ) ); | ||
} | ||
if ( offset.label !== undefined ) { | ||
label.push( dataview.getInt32( row + offset.label, this.littleEndian ) ); | ||
} | ||
} | ||
@@ -394,2 +435,4 @@ | ||
if ( color.length > 0 ) geometry.setAttribute( 'color', new Float32BufferAttribute( color, 3 ) ); | ||
if ( intensity.length > 0 ) geometry.setAttribute( 'intensity', new Float32BufferAttribute( intensity, 1 ) ); | ||
if ( label.length > 0 ) geometry.setAttribute( 'label', new Int32BufferAttribute( label, 1 ) ); | ||
@@ -406,6 +449,2 @@ geometry.computeBoundingSphere(); | ||
} else { | ||
material.color.setHex( Math.random() * 0xffffff ); | ||
} | ||
@@ -412,0 +451,0 @@ |
import Node from '../core/Node.js'; | ||
import AttributeNode from '../core/AttributeNode.js'; | ||
import VaryNode from '../core/VaryNode.js'; | ||
import VaryingNode from '../core/VaryingNode.js'; | ||
import ModelNode from '../accessors/ModelNode.js'; | ||
@@ -42,3 +42,3 @@ import CameraNode from '../accessors/CameraNode.js'; | ||
outputNode = new VaryNode( new NormalNode( NormalNode.GEOMETRY ) ); | ||
outputNode = new VaryingNode( new NormalNode( NormalNode.GEOMETRY ) ); | ||
@@ -48,3 +48,3 @@ } else if ( scope === NormalNode.VIEW ) { | ||
const vertexNormalNode = new OperatorNode( '*', new ModelNode( ModelNode.NORMAL_MATRIX ), new NormalNode( NormalNode.LOCAL ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryNode( vertexNormalNode ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryingNode( vertexNormalNode ) ); | ||
@@ -55,3 +55,3 @@ } else if ( scope === NormalNode.WORLD ) { | ||
const vertexNormalNode = new MathNode( MathNode.TRANSFORM_DIRECTION, new NormalNode( NormalNode.VIEW ), new CameraNode( CameraNode.VIEW_MATRIX ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryNode( vertexNormalNode ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryingNode( vertexNormalNode ) ); | ||
@@ -58,0 +58,0 @@ } |
import Node from '../core/Node.js'; | ||
import AttributeNode from '../core/AttributeNode.js'; | ||
import VaryNode from '../core/VaryNode.js'; | ||
import VaryingNode from '../core/VaryingNode.js'; | ||
import ModelNode from '../accessors/ModelNode.js'; | ||
@@ -42,3 +42,3 @@ import MathNode from '../math/MathNode.js'; | ||
outputNode = new VaryNode( new PositionNode( PositionNode.GEOMETRY ) ); | ||
outputNode = new VaryingNode( new PositionNode( PositionNode.GEOMETRY ) ); | ||
@@ -48,3 +48,3 @@ } else if ( scope === PositionNode.WORLD ) { | ||
const vertexPositionNode = new MathNode( MathNode.TRANSFORM_DIRECTION, new ModelNode( ModelNode.WORLD_MATRIX ), new PositionNode( PositionNode.LOCAL ) ); | ||
outputNode = new VaryNode( vertexPositionNode ); | ||
outputNode = new VaryingNode( vertexPositionNode ); | ||
@@ -54,3 +54,3 @@ } else if ( scope === PositionNode.VIEW ) { | ||
const vertexPositionNode = new OperatorNode( '*', new ModelNode( ModelNode.VIEW_MATRIX ), new PositionNode( PositionNode.LOCAL ) ); | ||
outputNode = new VaryNode( vertexPositionNode ); | ||
outputNode = new VaryingNode( vertexPositionNode ); | ||
@@ -60,3 +60,3 @@ } else if ( scope === PositionNode.VIEW_DIRECTION ) { | ||
const vertexPositionNode = new MathNode( MathNode.NEGATE, new PositionNode( PositionNode.VIEW ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryNode( vertexPositionNode ) ); | ||
outputNode = new MathNode( MathNode.NORMALIZE, new VaryingNode( vertexPositionNode ) ); | ||
@@ -63,0 +63,0 @@ } |
import Node from './Node.js'; | ||
import VaryNode from './VaryNode.js'; | ||
import VaryingNode from './VaryingNode.js'; | ||
@@ -61,5 +61,5 @@ class AttributeNode extends Node { | ||
const nodeVary = new VaryNode( this ); | ||
const nodeVarying = new VaryingNode( this ); | ||
return nodeVary.build( builder, attribute.type ); | ||
return nodeVarying.build( builder, attribute.type ); | ||
@@ -66,0 +66,0 @@ } |
import NodeUniform from './NodeUniform.js'; | ||
import NodeAttribute from './NodeAttribute.js'; | ||
import NodeVary from './NodeVary.js'; | ||
import NodeVarying from './NodeVarying.js'; | ||
import NodeVar from './NodeVar.js'; | ||
@@ -58,3 +58,3 @@ import NodeCode from './NodeCode.js'; | ||
this.attributes = []; | ||
this.varys = []; | ||
this.varyings = []; | ||
this.vars = { vertex: [], fragment: [], compute: [] }; | ||
@@ -460,22 +460,22 @@ this.flow = { code: '' }; | ||
getVaryFromNode( node, type ) { | ||
getVaryingFromNode( node, type ) { | ||
const nodeData = this.getDataFromNode( node, null ); | ||
let nodeVary = nodeData.vary; | ||
let nodeVarying = nodeData.varying; | ||
if ( nodeVary === undefined ) { | ||
if ( nodeVarying === undefined ) { | ||
const varys = this.varys; | ||
const index = varys.length; | ||
const varyings = this.varyings; | ||
const index = varyings.length; | ||
nodeVary = new NodeVary( 'nodeVary' + index, type ); | ||
nodeVarying = new NodeVarying( 'nodeVarying' + index, type ); | ||
varys.push( nodeVary ); | ||
varyings.push( nodeVarying ); | ||
nodeData.vary = nodeVary; | ||
nodeData.varying = nodeVarying; | ||
} | ||
return nodeVary; | ||
return nodeVarying; | ||
@@ -577,3 +577,3 @@ } | ||
getVarys( /*shaderStage*/ ) { | ||
getVaryings( /*shaderStage*/ ) { | ||
@@ -580,0 +580,0 @@ console.warn( 'Abstract function.' ); |
@@ -37,2 +37,4 @@ import Node from '../core/Node.js'; | ||
onInit() { } | ||
update( { renderer } ) { | ||
@@ -39,0 +41,0 @@ |
@@ -5,2 +5,3 @@ import NodeMaterial from './NodeMaterial.js'; | ||
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js'; | ||
import MeshPhysicalNodeMaterial from './MeshPhysicalNodeMaterial.js'; | ||
import PointsNodeMaterial from './PointsNodeMaterial.js'; | ||
@@ -14,2 +15,3 @@ import SpriteNodeMaterial from './SpriteNodeMaterial.js'; | ||
MeshStandardNodeMaterial, | ||
MeshPhysicalNodeMaterial, | ||
PointsNodeMaterial, | ||
@@ -26,4 +28,5 @@ SpriteNodeMaterial | ||
MeshStandardNodeMaterial, | ||
MeshPhysicalNodeMaterial, | ||
PointsNodeMaterial, | ||
SpriteNodeMaterial, | ||
SpriteNodeMaterial | ||
}; | ||
@@ -30,0 +33,0 @@ |
@@ -38,5 +38,2 @@ import NodeMaterial from './NodeMaterial.js'; | ||
this.clearcoatNode = null; | ||
this.clearcoatRoughnessNode = null; | ||
this.envNode = null; | ||
@@ -162,5 +159,2 @@ | ||
this.clearcoatNode = source.clearcoatNode; | ||
this.clearcoatRoughnessNode = source.clearcoatRoughnessNode; | ||
this.envNode = source.envNode; | ||
@@ -167,0 +161,0 @@ |
@@ -21,3 +21,3 @@ // core | ||
import NodeVar from './core/NodeVar.js'; | ||
import NodeVary from './core/NodeVary.js'; | ||
import NodeVarying from './core/NodeVarying.js'; | ||
import PropertyNode from './core/PropertyNode.js'; | ||
@@ -27,3 +27,3 @@ import TempNode from './core/TempNode.js'; | ||
import VarNode from './core/VarNode.js'; | ||
import VaryNode from './core/VaryNode.js'; | ||
import VaryingNode from './core/VaryingNode.js'; | ||
@@ -132,3 +132,3 @@ // accessors | ||
NodeVar, | ||
NodeVary, | ||
NodeVarying, | ||
PropertyNode, | ||
@@ -138,3 +138,3 @@ TempNode, | ||
VarNode, | ||
VaryNode, | ||
VaryingNode, | ||
@@ -242,3 +242,3 @@ // geometry | ||
NodeVar, | ||
NodeVary, | ||
NodeVarying, | ||
PropertyNode, | ||
@@ -248,3 +248,3 @@ TempNode, | ||
VarNode, | ||
VaryNode, | ||
VaryingNode, | ||
@@ -251,0 +251,0 @@ // geometry |
@@ -14,3 +14,3 @@ // core | ||
import VarNode from '../core/VarNode.js'; | ||
import VaryNode from '../core/VaryNode.js'; | ||
import VaryingNode from '../core/VaryingNode.js'; | ||
@@ -124,3 +124,3 @@ // accessors | ||
export const temp = label; | ||
export const vary = nodeProxy( VaryNode ); | ||
export const varying = nodeProxy( VaryingNode ); | ||
@@ -127,0 +127,0 @@ // accesors |
@@ -17,3 +17,4 @@ import NodeBuilder, { defaultShaderStages } from 'three-nodes/core/NodeBuilder.js'; | ||
PointsNodeMaterial: ShaderLib.points, | ||
MeshStandardNodeMaterial: ShaderLib.standard | ||
MeshStandardNodeMaterial: ShaderLib.standard, | ||
MeshPhysicalMaterial: ShaderLib.physical | ||
}; | ||
@@ -74,3 +75,4 @@ | ||
if ( material.isMeshStandardNodeMaterial ) type = 'MeshStandardNodeMaterial'; | ||
if ( material.isMeshPhysicalNodeMaterial ) type = 'MeshPhysicalMaterial'; | ||
else if ( material.isMeshStandardNodeMaterial ) type = 'MeshStandardNodeMaterial'; | ||
else if ( material.isMeshBasicNodeMaterial ) type = 'MeshBasicNodeMaterial'; | ||
@@ -135,12 +137,46 @@ else if ( material.isPointsNodeMaterial ) type = 'PointsNodeMaterial'; | ||
if ( material.clearcoatNode && material.clearcoatNode.isNode ) { | ||
if ( material.isMeshPhysicalNodeMaterial ) { | ||
this.addSlot( 'fragment', new SlotNode( material.clearcoatNode, 'CLEARCOAT', 'float' ) ); | ||
if ( material.clearcoatNode && material.clearcoatNode.isNode ) { | ||
} | ||
this.addSlot( 'fragment', new SlotNode( material.clearcoatNode, 'CLEARCOAT', 'float' ) ); | ||
if ( material.clearcoatRoughnessNode && material.clearcoatRoughnessNode.isNode ) { | ||
if ( material.clearcoatRoughnessNode && material.clearcoatRoughnessNode.isNode ) { | ||
this.addSlot( 'fragment', new SlotNode( material.clearcoatRoughnessNode, 'CLEARCOAT_ROUGHNESS', 'float' ) ); | ||
this.addSlot( 'fragment', new SlotNode( material.clearcoatRoughnessNode, 'CLEARCOAT_ROUGHNESS', 'float' ) ); | ||
} | ||
if ( material.clearcoatNormalNode && material.clearcoatNormalNode.isNode ) { | ||
this.addSlot( 'fragment', new SlotNode( material.clearcoatNormalNode, 'CLEARCOAT_NORMAL', 'vec3' ) ); | ||
} | ||
material.defines.USE_CLEARCOAT = ''; | ||
} else { | ||
delete material.defines.USE_CLEARCOAT; | ||
} | ||
if ( material.sheenNode && material.sheenNode.isNode ) { | ||
this.addSlot( 'fragment', new SlotNode( material.sheenNode, 'SHEEN', 'vec3' ) ); | ||
if ( material.sheenRoughnessNode && material.sheenRoughnessNode.isNode ) { | ||
this.addSlot( 'fragment', new SlotNode( material.sheenRoughnessNode, 'SHEEN_ROUGHNESS', 'float' ) ); | ||
} | ||
material.defines.USE_SHEEN = ''; | ||
} else { | ||
delete material.defines.USE_SHEEN; | ||
} | ||
} | ||
@@ -256,6 +292,4 @@ | ||
for ( let index = 0; index < attributes.length; index ++ ) { | ||
for ( const attribute of attributes ) { | ||
const attribute = attributes[ index ]; | ||
// ignore common attributes to prevent redefinitions | ||
@@ -275,14 +309,12 @@ if ( attribute.name === 'uv' || attribute.name === 'position' || attribute.name === 'normal' ) | ||
getVarys( /* shaderStage */ ) { | ||
getVaryings( /* shaderStage */ ) { | ||
let snippet = ''; | ||
const varys = this.varys; | ||
const varyings = this.varyings; | ||
for ( let index = 0; index < varys.length; index ++ ) { | ||
for ( const varying of varyings ) { | ||
const vary = varys[ index ]; | ||
snippet += `varying ${varying.type} ${varying.name}; `; | ||
snippet += `varying ${vary.type} ${vary.name}; `; | ||
} | ||
@@ -327,3 +359,3 @@ | ||
this.shader[ shaderProperty ] = this.shader[ shaderProperty ].replaceAll( source, target ); | ||
this[ shaderProperty ] = this[ shaderProperty ].replaceAll( source, target ); | ||
@@ -373,3 +405,3 @@ } | ||
const attributes = this.getAttributes( shaderStage ); | ||
const varys = this.getVarys( shaderStage ); | ||
const varyings = this.getVaryings( shaderStage ); | ||
const vars = this.getVars( shaderStage ); | ||
@@ -387,4 +419,4 @@ const codes = this.getCodes( shaderStage ); | ||
// varys | ||
${varys} | ||
// varyings | ||
${varyings} | ||
@@ -444,2 +476,3 @@ // vars | ||
this.parseInclude( 'fragment', 'lights_physical_fragment' ); | ||
this.parseInclude( 'fragment', 'clearcoat_normal_fragment_begin' ); | ||
@@ -454,2 +487,5 @@ const colorSlot = this.getSlot( 'fragment', 'COLOR' ); | ||
const clearcoatRoughnessNode = this.getSlot( 'fragment', 'CLEARCOAT_ROUGHNESS' ); | ||
const clearcoatNormalNode = this.getSlot( 'fragment', 'CLEARCOAT_NORMAL' ); | ||
const sheenNode = this.getSlot( 'fragment', 'SHEEN' ); | ||
const sheenRoughnessNode = this.getSlot( 'fragment', 'SHEEN_ROUGHNESS' ); | ||
const iridescenceNode = this.getSlot( 'fragment', 'IRIDESCENCE' ); | ||
@@ -526,16 +562,46 @@ const iridescenceIORNode = this.getSlot( 'fragment', 'IRIDESCENCE_IOR' ); | ||
'fragment', | ||
'material.clearcoatRoughness = clearcoatRoughness;', | ||
'material.clearcoat = clearcoat;', | ||
`${clearcoatNode.code}\n\tmaterial.clearcoat = ${clearcoatNode.result};` | ||
); | ||
if ( clearcoatRoughnessNode !== undefined ) { | ||
this.addCodeAfterSnippet( | ||
'fragment', | ||
'material.clearcoatRoughness = clearcoatRoughness;', | ||
`${clearcoatRoughnessNode.code}\n\tmaterial.clearcoatRoughness = ${clearcoatRoughnessNode.result};` | ||
); | ||
} | ||
if ( clearcoatNormalNode !== undefined ) { | ||
this.addCodeAfterSnippet( | ||
'fragment', | ||
'vec3 clearcoatNormal = geometryNormal;', | ||
`${clearcoatNormalNode.code}\n\tclearcoatNormal = ${clearcoatNormalNode.result};` | ||
); | ||
} | ||
} | ||
if ( clearcoatRoughnessNode !== undefined ) { | ||
if ( sheenNode !== undefined ) { | ||
this.addCodeAfterSnippet( | ||
'fragment', | ||
'material.clearcoatRoughness = clearcoatRoughness;', | ||
`${clearcoatRoughnessNode.code}\n\tmaterial.clearcoatRoughness = ${clearcoatRoughnessNode.result};` | ||
'material.sheenColor = sheenColor;', | ||
`${sheenNode.code}\n\tmaterial.sheenColor = ${sheenNode.result};` | ||
); | ||
if ( sheenRoughnessNode !== undefined ) { | ||
this.replaceCode( | ||
'fragment', | ||
'material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );', | ||
`${sheenRoughnessNode.code}\n\tmaterial.sheenRoughness = clamp( ${sheenRoughnessNode.result}, 0.07, 1.0 );` | ||
); | ||
} | ||
} | ||
@@ -545,3 +611,3 @@ | ||
this.addCodeAfterSnippet( | ||
this.addCodeAfterInclude( | ||
'fragment', | ||
@@ -556,3 +622,3 @@ 'iridescence_fragment', | ||
this.addCodeAfterSnippet( | ||
this.addCodeAfterInclude( | ||
'fragment', | ||
@@ -567,3 +633,3 @@ 'iridescence_fragment', | ||
this.addCodeAfterSnippet( | ||
this.addCodeAfterInclude( | ||
'fragment', | ||
@@ -570,0 +636,0 @@ 'iridescence_fragment', |
@@ -206,7 +206,7 @@ import WebGPUUniformsGroup from '../WebGPUUniformsGroup.js'; | ||
if ( node.isNodeVary === true ) { | ||
if ( node.isNodeVarying === true ) { | ||
if ( shaderStage === 'vertex' ) { | ||
return `NodeVarys.${ node.name }`; | ||
return `NodeVaryings.${ node.name }`; | ||
@@ -461,3 +461,3 @@ } | ||
getVarys( shaderStage ) { | ||
getVaryings( shaderStage ) { | ||
@@ -470,9 +470,9 @@ const snippets = []; | ||
const varys = this.varys; | ||
const varyings = this.varyings; | ||
for ( let index = 0; index < varys.length; index ++ ) { | ||
for ( let index = 0; index < varyings.length; index ++ ) { | ||
const vary = varys[ index ]; | ||
const varying = varyings[ index ]; | ||
snippets.push( `@location( ${index} ) ${ vary.name } : ${ this.getType( vary.type ) }` ); | ||
snippets.push( `@location( ${index} ) ${ varying.name } : ${ this.getType( varying.type ) }` ); | ||
@@ -483,9 +483,9 @@ } | ||
const varys = this.varys; | ||
const varyings = this.varyings; | ||
for ( let index = 0; index < varys.length; index ++ ) { | ||
for ( let index = 0; index < varyings.length; index ++ ) { | ||
const vary = varys[ index ]; | ||
const varying = varyings[ index ]; | ||
snippets.push( `@location( ${index} ) ${ vary.name } : ${ this.getType( vary.type ) }` ); | ||
snippets.push( `@location( ${index} ) ${ varying.name } : ${ this.getType( varying.type ) }` ); | ||
@@ -504,3 +504,3 @@ } | ||
return shaderStage === 'vertex' ? this._getWGSLStruct( 'NodeVarysStruct', '\t' + code ) : code; | ||
return shaderStage === 'vertex' ? this._getWGSLStruct( 'NodeVaryingsStruct', '\t' + code ) : code; | ||
@@ -620,3 +620,3 @@ } | ||
flow += 'NodeVarys.Vertex = '; | ||
flow += 'NodeVaryings.Vertex = '; | ||
@@ -639,3 +639,3 @@ } else if ( shaderStage === 'fragment' ) { | ||
stageData.attributes = this.getAttributes( shaderStage ); | ||
stageData.varys = this.getVarys( shaderStage ); | ||
stageData.varyings = this.getVaryings( shaderStage ); | ||
stageData.vars = this.getVars( shaderStage ); | ||
@@ -711,4 +711,4 @@ stageData.codes = this.getCodes( shaderStage ); | ||
// varys | ||
${shaderData.varys} | ||
// varyings | ||
${shaderData.varyings} | ||
@@ -719,6 +719,6 @@ // codes | ||
@vertex | ||
fn main( ${shaderData.attributes} ) -> NodeVarysStruct { | ||
fn main( ${shaderData.attributes} ) -> NodeVaryingsStruct { | ||
// system | ||
var NodeVarys: NodeVarysStruct; | ||
var NodeVaryings: NodeVaryingsStruct; | ||
@@ -731,3 +731,3 @@ // vars | ||
return NodeVarys; | ||
return NodeVaryings; | ||
@@ -750,3 +750,3 @@ } | ||
@fragment | ||
fn main( ${shaderData.varys} ) -> @location( 0 ) vec4<f32> { | ||
fn main( ${shaderData.varyings} ) -> @location( 0 ) vec4<f32> { | ||
@@ -753,0 +753,0 @@ // vars |
@@ -17,2 +17,8 @@ import WebGPUProgrammableStage from './WebGPUProgrammableStage.js'; | ||
has( computeNode ) { | ||
return this.pipelines.get( computeNode ) !== undefined; | ||
} | ||
get( computeNode ) { | ||
@@ -19,0 +25,0 @@ |
@@ -15,2 +15,3 @@ import { GPUIndexFormat, GPUTextureFormat, GPUStoreOp } from './constants.js'; | ||
import WebGPUNodes from './nodes/WebGPUNodes.js'; | ||
import WebGPUUtils from './WebGPUUtils.js'; | ||
@@ -61,3 +62,22 @@ import { Frustum, Matrix4, Vector3, Color, LinearEncoding } from 'three'; | ||
Frustum.prototype.setFromProjectionMatrix = function( m ) { | ||
const planes = this.planes; | ||
const me = m.elements; | ||
const me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ]; | ||
const me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ]; | ||
const me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ]; | ||
const me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ]; | ||
planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize(); | ||
planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize(); | ||
planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize(); | ||
planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize(); | ||
planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize(); | ||
planes[ 5 ].setComponents( me2, me6, me10, me14 ).normalize(); | ||
return this; | ||
}; | ||
const _frustum = new Frustum(); | ||
@@ -192,5 +212,6 @@ const _projScreenMatrix = new Matrix4(); | ||
this._objects = new WebGPUObjects( this._geometries, this._info ); | ||
this._utils = new WebGPUUtils( this ); | ||
this._nodes = new WebGPUNodes( this, this._properties ); | ||
this._computePipelines = new WebGPUComputePipelines( device, this._nodes ); | ||
this._renderPipelines = new WebGPURenderPipelines( this, device, parameters.sampleCount, this._nodes ); | ||
this._renderPipelines = new WebGPURenderPipelines( device, this._nodes, this._utils ); | ||
this._bindings = this._renderPipelines.bindings = new WebGPUBindings( device, this._info, this._properties, this._textures, this._renderPipelines, this._computePipelines, this._attributes, this._nodes ); | ||
@@ -488,51 +509,2 @@ this._renderLists = new WebGPURenderLists(); | ||
getCurrentEncoding() { | ||
const renderTarget = this.getRenderTarget(); | ||
return ( renderTarget !== null ) ? renderTarget.texture.encoding : this.outputEncoding; | ||
} | ||
getCurrentColorFormat() { | ||
let format; | ||
const renderTarget = this.getRenderTarget(); | ||
if ( renderTarget !== null ) { | ||
const renderTargetProperties = this._properties.get( renderTarget ); | ||
format = renderTargetProperties.colorTextureFormat; | ||
} else { | ||
format = GPUTextureFormat.BGRA8Unorm; // default context format | ||
} | ||
return format; | ||
} | ||
getCurrentDepthStencilFormat() { | ||
let format; | ||
const renderTarget = this.getRenderTarget(); | ||
if ( renderTarget !== null ) { | ||
const renderTargetProperties = this._properties.get( renderTarget ); | ||
format = renderTargetProperties.depthTextureFormat; | ||
} else { | ||
format = GPUTextureFormat.Depth24PlusStencil8; | ||
} | ||
return format; | ||
} | ||
getClearColor( target ) { | ||
@@ -623,2 +595,4 @@ | ||
const device = this._device; | ||
const computePipelines = this._computePipelines; | ||
const cmdEncoder = device.createCommandEncoder( {} ); | ||
@@ -629,5 +603,13 @@ const passEncoder = cmdEncoder.beginComputePass(); | ||
// onInit | ||
if ( computePipelines.has( computeNode ) === false ) { | ||
computeNode.onInit( { renderer: this } ); | ||
} | ||
// pipeline | ||
const pipeline = this._computePipelines.get( computeNode ); | ||
const pipeline = computePipelines.get( computeNode ); | ||
passEncoder.setPipeline( pipeline ); | ||
@@ -634,0 +616,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { GPUPrimitiveTopology, GPUIndexFormat, GPUCompareFunction, GPUFrontFace, GPUCullMode, GPUVertexFormat, GPUBlendFactor, GPUBlendOperation, BlendColorFactor, OneMinusBlendColorFactor, GPUColorWriteFlags, GPUStencilOperation, GPUInputStepMode } from './constants.js'; | ||
import { GPUIndexFormat, GPUCompareFunction, GPUFrontFace, GPUCullMode, GPUVertexFormat, GPUBlendFactor, GPUBlendOperation, BlendColorFactor, OneMinusBlendColorFactor, GPUColorWriteFlags, GPUStencilOperation, GPUInputStepMode } from './constants.js'; | ||
import { | ||
@@ -14,3 +14,3 @@ FrontSide, BackSide, DoubleSide, | ||
constructor( device, renderer, sampleCount ) { | ||
constructor( device, utils ) { | ||
@@ -24,4 +24,3 @@ this.cacheKey = null; | ||
this._device = device; | ||
this._renderer = renderer; | ||
this._sampleCount = sampleCount; | ||
this._utils = utils; | ||
@@ -94,4 +93,5 @@ } | ||
const depthCompare = this._getDepthCompare( material ); | ||
const colorFormat = this._renderer.getCurrentColorFormat(); | ||
const depthStencilFormat = this._renderer.getCurrentDepthStencilFormat(); | ||
const colorFormat = this._utils.getCurrentColorFormat(); | ||
const depthStencilFormat = this._utils.getCurrentDepthStencilFormat(); | ||
const sampleCount = this._utils.getSampleCount(); | ||
@@ -119,3 +119,3 @@ this.pipeline = this._device.createRenderPipeline( { | ||
multisample: { | ||
count: this._sampleCount | ||
count: sampleCount | ||
}, | ||
@@ -437,3 +437,3 @@ layout: 'auto' | ||
descriptor.topology = this._getPrimitiveTopology( object ); | ||
descriptor.topology = this._utils.getPrimitiveTopology( object ); | ||
@@ -475,11 +475,2 @@ if ( object.isLine === true && object.isLineSegments !== true ) { | ||
_getPrimitiveTopology( object ) { | ||
if ( object.isMesh ) return GPUPrimitiveTopology.TriangleList; | ||
else if ( object.isPoints ) return GPUPrimitiveTopology.PointList; | ||
else if ( object.isLineSegments ) return GPUPrimitiveTopology.LineList; | ||
else if ( object.isLine ) return GPUPrimitiveTopology.LineStrip; | ||
} | ||
_getStencilCompare( material ) { | ||
@@ -486,0 +477,0 @@ |
@@ -6,10 +6,10 @@ import WebGPURenderPipeline from './WebGPURenderPipeline.js'; | ||
constructor( renderer, device, sampleCount, nodes, bindings = null ) { | ||
constructor( device, nodes, utils ) { | ||
this.renderer = renderer; | ||
this.device = device; | ||
this.sampleCount = sampleCount; | ||
this.nodes = nodes; | ||
this.bindings = bindings; | ||
this.utils = utils; | ||
this.bindings = null; | ||
this.pipelines = []; | ||
@@ -129,3 +129,3 @@ this.objectCache = new WeakMap(); | ||
pipeline = new WebGPURenderPipeline( this.device, this.renderer, this.sampleCount ); | ||
pipeline = new WebGPURenderPipeline( this.device, this.utils ); | ||
pipeline.init( cacheKey, stageVertex, stageFragment, object, nodeBuilder ); | ||
@@ -144,3 +144,3 @@ | ||
const material = object.material; | ||
const renderer = this.renderer; | ||
const utils = this.utils; | ||
@@ -158,4 +158,5 @@ const parameters = [ | ||
material.side, | ||
this.sampleCount, | ||
renderer.getCurrentEncoding(), renderer.getCurrentColorFormat(), renderer.getCurrentDepthStencilFormat() | ||
utils.getSampleCount(), | ||
utils.getCurrentEncoding(), utils.getCurrentColorFormat(), utils.getCurrentDepthStencilFormat(), | ||
utils.getPrimitiveTopology( object ) | ||
]; | ||
@@ -274,12 +275,13 @@ | ||
const renderer = this.renderer; | ||
const utils = this.utils; | ||
const encoding = renderer.getCurrentEncoding(); | ||
const colorFormat = renderer.getCurrentColorFormat(); | ||
const depthStencilFormat = renderer.getCurrentDepthStencilFormat(); | ||
const sampleCount = utils.getSampleCount(); | ||
const encoding = utils.getCurrentEncoding(); | ||
const colorFormat = utils.getCurrentColorFormat(); | ||
const depthStencilFormat = utils.getCurrentDepthStencilFormat(); | ||
if ( cache.sampleCount !== this.sampleCount || cache.encoding !== encoding || | ||
if ( cache.sampleCount !== sampleCount || cache.encoding !== encoding || | ||
cache.colorFormat !== colorFormat || cache.depthStencilFormat !== depthStencilFormat ) { | ||
cache.sampleCount = this.sampleCount; | ||
cache.sampleCount = sampleCount; | ||
cache.encoding = encoding; | ||
@@ -286,0 +288,0 @@ cache.colorFormat = colorFormat; |
@@ -38,3 +38,3 @@ /** | ||
float l = linearToRelativeLuminance( texel.rgb ); | ||
float l = luminance( texel.rgb ); | ||
@@ -41,0 +41,0 @@ gl_FragColor = vec4( l, l, l, texel.w ); |
@@ -54,3 +54,3 @@ /** | ||
// Calculate the luminance of the current pixel | ||
float fLumPixel = linearToRelativeLuminance( vColor ); | ||
float fLumPixel = luminance( vColor ); | ||
@@ -57,0 +57,0 @@ // Apply the modified operator (Eq. 4) |
{ | ||
"name": "three", | ||
"version": "0.142.0", | ||
"version": "0.143.0", | ||
"description": "JavaScript 3D library", | ||
@@ -140,11 +140,11 @@ "type": "module", | ||
"devDependencies": { | ||
"@babel/core": "^7.18.2", | ||
"@babel/core": "^7.18.6", | ||
"@babel/eslint-parser": "^7.18.2", | ||
"@babel/plugin-proposal-class-properties": "^7.17.12", | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/plugin-proposal-class-properties": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-node-resolve": "^13.3.0", | ||
"chalk": "^5.0.1", | ||
"concurrently": "^7.2.1", | ||
"eslint": "^8.16.0", | ||
"concurrently": "^7.2.2", | ||
"eslint": "^8.18.0", | ||
"eslint-config-mdcs": "^5.0.0", | ||
@@ -154,3 +154,3 @@ "eslint-plugin-compat": "^4.0.2", | ||
"eslint-plugin-import": "^2.26.0", | ||
"rollup": "^2.75.0", | ||
"rollup": "^2.75.7", | ||
"rollup-plugin-filesize": "^9.1.2", | ||
@@ -157,0 +157,0 @@ "rollup-plugin-terser": "^7.0.2", |
@@ -1,3 +0,2 @@ | ||
three.js | ||
======== | ||
# three.js | ||
@@ -10,3 +9,3 @@ [![NPM Package][npm]][npm-url] | ||
#### JavaScript 3D library #### | ||
#### JavaScript 3D library | ||
@@ -23,3 +22,3 @@ The aim of the project is to create an easy to use, lightweight, cross-browser, general purpose 3D library. The current builds only include a WebGL renderer but WebGPU (experimental), SVG and CSS3D renderers are also available in the examples. | ||
### Usage ### | ||
### Usage | ||
@@ -63,3 +62,3 @@ This code creates a scene, a camera, and a geometric cube, and it adds the cube to the scene. It then creates a `WebGL` renderer for the scene and camera, and it adds that viewport to the `document.body` element. Finally, it animates the cube within the scene for the camera. | ||
### Cloning this repository ### | ||
### Cloning this repository | ||
@@ -72,3 +71,3 @@ Cloning the repo with all its history results in a ~2 GB download. If you don't need the whole history you can use the `depth` parameter to significantly reduce download size. | ||
### Change log ### | ||
### Change log | ||
@@ -75,0 +74,0 @@ [Releases](https://github.com/mrdoob/three.js/releases) |
@@ -1,2 +0,2 @@ | ||
import { AnimationUtils } from './AnimationUtils.js'; | ||
import * as AnimationUtils from './AnimationUtils.js'; | ||
import { KeyframeTrack } from './KeyframeTrack.js'; | ||
@@ -3,0 +3,0 @@ import { BooleanKeyframeTrack } from './tracks/BooleanKeyframeTrack.js'; |
@@ -10,3 +10,3 @@ import { AnimationAction } from './AnimationAction.js'; | ||
const _controlInterpolantsResultBuffer = /*@__PURE__*/ new Float32Array( 1 ); | ||
const _controlInterpolantsResultBuffer = new Float32Array( 1 ); | ||
@@ -13,0 +13,0 @@ |
import { Quaternion } from '../math/Quaternion.js'; | ||
import { AdditiveAnimationBlendMode } from '../constants.js'; | ||
const AnimationUtils = { | ||
// same as Array.prototype.slice, but also works on typed arrays | ||
function arraySlice( array, from, to ) { | ||
// same as Array.prototype.slice, but also works on typed arrays | ||
arraySlice: function ( array, from, to ) { | ||
if ( isTypedArray( array ) ) { | ||
if ( AnimationUtils.isTypedArray( array ) ) { | ||
// in ios9 array.subarray(from, undefined) will return empty array | ||
// but array.subarray(from) or array.subarray(from, len) is correct | ||
return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) ); | ||
// in ios9 array.subarray(from, undefined) will return empty array | ||
// but array.subarray(from) or array.subarray(from, len) is correct | ||
return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) ); | ||
} | ||
} | ||
return array.slice( from, to ); | ||
return array.slice( from, to ); | ||
} | ||
}, | ||
// converts an array to a specific type | ||
function convertArray( array, type, forceClone ) { | ||
// converts an array to a specific type | ||
convertArray: function ( array, type, forceClone ) { | ||
if ( ! array || // let 'undefined' and 'null' pass | ||
! forceClone && array.constructor === type ) return array; | ||
if ( ! array || // let 'undefined' and 'null' pass | ||
! forceClone && array.constructor === type ) return array; | ||
if ( typeof type.BYTES_PER_ELEMENT === 'number' ) { | ||
if ( typeof type.BYTES_PER_ELEMENT === 'number' ) { | ||
return new type( array ); // create typed array | ||
return new type( array ); // create typed array | ||
} | ||
} | ||
return Array.prototype.slice.call( array ); // create Array | ||
return Array.prototype.slice.call( array ); // create Array | ||
} | ||
}, | ||
function isTypedArray( object ) { | ||
isTypedArray: function ( object ) { | ||
return ArrayBuffer.isView( object ) && | ||
! ( object instanceof DataView ); | ||
return ArrayBuffer.isView( object ) && | ||
! ( object instanceof DataView ); | ||
} | ||
}, | ||
// returns an array by which times and values can be sorted | ||
function getKeyframeOrder( times ) { | ||
// returns an array by which times and values can be sorted | ||
getKeyframeOrder: function ( times ) { | ||
function compareTime( i, j ) { | ||
function compareTime( i, j ) { | ||
return times[ i ] - times[ j ]; | ||
return times[ i ] - times[ j ]; | ||
} | ||
} | ||
const n = times.length; | ||
const result = new Array( n ); | ||
for ( let i = 0; i !== n; ++ i ) result[ i ] = i; | ||
const n = times.length; | ||
const result = new Array( n ); | ||
for ( let i = 0; i !== n; ++ i ) result[ i ] = i; | ||
result.sort( compareTime ); | ||
result.sort( compareTime ); | ||
return result; | ||
return result; | ||
} | ||
}, | ||
// uses the array previously returned by 'getKeyframeOrder' to sort data | ||
function sortedArray( values, stride, order ) { | ||
// uses the array previously returned by 'getKeyframeOrder' to sort data | ||
sortedArray: function ( values, stride, order ) { | ||
const nValues = values.length; | ||
const result = new values.constructor( nValues ); | ||
const nValues = values.length; | ||
const result = new values.constructor( nValues ); | ||
for ( let i = 0, dstOffset = 0; dstOffset !== nValues; ++ i ) { | ||
for ( let i = 0, dstOffset = 0; dstOffset !== nValues; ++ i ) { | ||
const srcOffset = order[ i ] * stride; | ||
const srcOffset = order[ i ] * stride; | ||
for ( let j = 0; j !== stride; ++ j ) { | ||
for ( let j = 0; j !== stride; ++ j ) { | ||
result[ dstOffset ++ ] = values[ srcOffset + j ]; | ||
result[ dstOffset ++ ] = values[ srcOffset + j ]; | ||
} | ||
} | ||
return result; | ||
} | ||
}, | ||
return result; | ||
// function for parsing AOS keyframe formats | ||
flattenJSON: function ( jsonKeys, times, values, valuePropertyName ) { | ||
} | ||
let i = 1, key = jsonKeys[ 0 ]; | ||
// function for parsing AOS keyframe formats | ||
function flattenJSON( jsonKeys, times, values, valuePropertyName ) { | ||
while ( key !== undefined && key[ valuePropertyName ] === undefined ) { | ||
let i = 1, key = jsonKeys[ 0 ]; | ||
key = jsonKeys[ i ++ ]; | ||
while ( key !== undefined && key[ valuePropertyName ] === undefined ) { | ||
} | ||
key = jsonKeys[ i ++ ]; | ||
if ( key === undefined ) return; // no data | ||
} | ||
let value = key[ valuePropertyName ]; | ||
if ( value === undefined ) return; // no data | ||
if ( key === undefined ) return; // no data | ||
if ( Array.isArray( value ) ) { | ||
let value = key[ valuePropertyName ]; | ||
if ( value === undefined ) return; // no data | ||
do { | ||
if ( Array.isArray( value ) ) { | ||
value = key[ valuePropertyName ]; | ||
do { | ||
if ( value !== undefined ) { | ||
value = key[ valuePropertyName ]; | ||
times.push( key.time ); | ||
values.push.apply( values, value ); // push all elements | ||
if ( value !== undefined ) { | ||
} | ||
times.push( key.time ); | ||
values.push.apply( values, value ); // push all elements | ||
key = jsonKeys[ i ++ ]; | ||
} | ||
} while ( key !== undefined ); | ||
key = jsonKeys[ i ++ ]; | ||
} else if ( value.toArray !== undefined ) { | ||
} while ( key !== undefined ); | ||
// ...assume THREE.Math-ish | ||
} else if ( value.toArray !== undefined ) { | ||
do { | ||
// ...assume THREE.Math-ish | ||
value = key[ valuePropertyName ]; | ||
do { | ||
if ( value !== undefined ) { | ||
value = key[ valuePropertyName ]; | ||
times.push( key.time ); | ||
value.toArray( values, values.length ); | ||
if ( value !== undefined ) { | ||
} | ||
times.push( key.time ); | ||
value.toArray( values, values.length ); | ||
key = jsonKeys[ i ++ ]; | ||
} | ||
} while ( key !== undefined ); | ||
key = jsonKeys[ i ++ ]; | ||
} else { | ||
} while ( key !== undefined ); | ||
// otherwise push as-is | ||
} else { | ||
do { | ||
// otherwise push as-is | ||
value = key[ valuePropertyName ]; | ||
do { | ||
if ( value !== undefined ) { | ||
value = key[ valuePropertyName ]; | ||
times.push( key.time ); | ||
values.push( value ); | ||
if ( value !== undefined ) { | ||
} | ||
times.push( key.time ); | ||
values.push( value ); | ||
key = jsonKeys[ i ++ ]; | ||
} | ||
} while ( key !== undefined ); | ||
key = jsonKeys[ i ++ ]; | ||
} | ||
} while ( key !== undefined ); | ||
}, | ||
} | ||
subclip: function ( sourceClip, name, startFrame, endFrame, fps = 30 ) { | ||
} | ||
const clip = sourceClip.clone(); | ||
function subclip( sourceClip, name, startFrame, endFrame, fps = 30 ) { | ||
clip.name = name; | ||
const clip = sourceClip.clone(); | ||
const tracks = []; | ||
clip.name = name; | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
const tracks = []; | ||
const track = clip.tracks[ i ]; | ||
const valueSize = track.getValueSize(); | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
const times = []; | ||
const values = []; | ||
const track = clip.tracks[ i ]; | ||
const valueSize = track.getValueSize(); | ||
for ( let j = 0; j < track.times.length; ++ j ) { | ||
const times = []; | ||
const values = []; | ||
const frame = track.times[ j ] * fps; | ||
for ( let j = 0; j < track.times.length; ++ j ) { | ||
if ( frame < startFrame || frame >= endFrame ) continue; | ||
const frame = track.times[ j ] * fps; | ||
times.push( track.times[ j ] ); | ||
if ( frame < startFrame || frame >= endFrame ) continue; | ||
for ( let k = 0; k < valueSize; ++ k ) { | ||
times.push( track.times[ j ] ); | ||
values.push( track.values[ j * valueSize + k ] ); | ||
for ( let k = 0; k < valueSize; ++ k ) { | ||
} | ||
values.push( track.values[ j * valueSize + k ] ); | ||
} | ||
if ( times.length === 0 ) continue; | ||
} | ||
track.times = AnimationUtils.convertArray( times, track.times.constructor ); | ||
track.values = AnimationUtils.convertArray( values, track.values.constructor ); | ||
if ( times.length === 0 ) continue; | ||
tracks.push( track ); | ||
track.times = convertArray( times, track.times.constructor ); | ||
track.values = convertArray( values, track.values.constructor ); | ||
} | ||
tracks.push( track ); | ||
clip.tracks = tracks; | ||
} | ||
// find minimum .times value across all tracks in the trimmed clip | ||
clip.tracks = tracks; | ||
let minStartTime = Infinity; | ||
// find minimum .times value across all tracks in the trimmed clip | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
let minStartTime = Infinity; | ||
if ( minStartTime > clip.tracks[ i ].times[ 0 ] ) { | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
minStartTime = clip.tracks[ i ].times[ 0 ]; | ||
if ( minStartTime > clip.tracks[ i ].times[ 0 ] ) { | ||
} | ||
minStartTime = clip.tracks[ i ].times[ 0 ]; | ||
} | ||
// shift all tracks such that clip begins at t=0 | ||
} | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
// shift all tracks such that clip begins at t=0 | ||
clip.tracks[ i ].shift( - 1 * minStartTime ); | ||
for ( let i = 0; i < clip.tracks.length; ++ i ) { | ||
} | ||
clip.tracks[ i ].shift( - 1 * minStartTime ); | ||
clip.resetDuration(); | ||
} | ||
return clip; | ||
clip.resetDuration(); | ||
}, | ||
return clip; | ||
makeClipAdditive: function ( targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30 ) { | ||
} | ||
if ( fps <= 0 ) fps = 30; | ||
function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30 ) { | ||
const numTracks = referenceClip.tracks.length; | ||
const referenceTime = referenceFrame / fps; | ||
if ( fps <= 0 ) fps = 30; | ||
// Make each track's values relative to the values at the reference frame | ||
for ( let i = 0; i < numTracks; ++ i ) { | ||
const numTracks = referenceClip.tracks.length; | ||
const referenceTime = referenceFrame / fps; | ||
const referenceTrack = referenceClip.tracks[ i ]; | ||
const referenceTrackType = referenceTrack.ValueTypeName; | ||
// Make each track's values relative to the values at the reference frame | ||
for ( let i = 0; i < numTracks; ++ i ) { | ||
// Skip this track if it's non-numeric | ||
if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) continue; | ||
const referenceTrack = referenceClip.tracks[ i ]; | ||
const referenceTrackType = referenceTrack.ValueTypeName; | ||
// Find the track in the target clip whose name and type matches the reference track | ||
const targetTrack = targetClip.tracks.find( function ( track ) { | ||
// Skip this track if it's non-numeric | ||
if ( referenceTrackType === 'bool' || referenceTrackType === 'string' ) continue; | ||
return track.name === referenceTrack.name | ||
&& track.ValueTypeName === referenceTrackType; | ||
// Find the track in the target clip whose name and type matches the reference track | ||
const targetTrack = targetClip.tracks.find( function ( track ) { | ||
} ); | ||
return track.name === referenceTrack.name | ||
&& track.ValueTypeName === referenceTrackType; | ||
if ( targetTrack === undefined ) continue; | ||
} ); | ||
let referenceOffset = 0; | ||
const referenceValueSize = referenceTrack.getValueSize(); | ||
if ( targetTrack === undefined ) continue; | ||
if ( referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { | ||
let referenceOffset = 0; | ||
const referenceValueSize = referenceTrack.getValueSize(); | ||
referenceOffset = referenceValueSize / 3; | ||
if ( referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { | ||
} | ||
referenceOffset = referenceValueSize / 3; | ||
let targetOffset = 0; | ||
const targetValueSize = targetTrack.getValueSize(); | ||
} | ||
if ( targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { | ||
let targetOffset = 0; | ||
const targetValueSize = targetTrack.getValueSize(); | ||
targetOffset = targetValueSize / 3; | ||
if ( targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { | ||
} | ||
targetOffset = targetValueSize / 3; | ||
const lastIndex = referenceTrack.times.length - 1; | ||
let referenceValue; | ||
} | ||
// Find the value to subtract out of the track | ||
if ( referenceTime <= referenceTrack.times[ 0 ] ) { | ||
const lastIndex = referenceTrack.times.length - 1; | ||
let referenceValue; | ||
// Reference frame is earlier than the first keyframe, so just use the first keyframe | ||
const startIndex = referenceOffset; | ||
const endIndex = referenceValueSize - referenceOffset; | ||
referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); | ||
// Find the value to subtract out of the track | ||
if ( referenceTime <= referenceTrack.times[ 0 ] ) { | ||
} else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { | ||
// Reference frame is earlier than the first keyframe, so just use the first keyframe | ||
const startIndex = referenceOffset; | ||
const endIndex = referenceValueSize - referenceOffset; | ||
referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex ); | ||
// Reference frame is after the last keyframe, so just use the last keyframe | ||
const startIndex = lastIndex * referenceValueSize + referenceOffset; | ||
const endIndex = startIndex + referenceValueSize - referenceOffset; | ||
referenceValue = AnimationUtils.arraySlice( referenceTrack.values, startIndex, endIndex ); | ||
} else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) { | ||
} else { | ||
// Reference frame is after the last keyframe, so just use the last keyframe | ||
const startIndex = lastIndex * referenceValueSize + referenceOffset; | ||
const endIndex = startIndex + referenceValueSize - referenceOffset; | ||
referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex ); | ||
// Interpolate to the reference value | ||
const interpolant = referenceTrack.createInterpolant(); | ||
const startIndex = referenceOffset; | ||
const endIndex = referenceValueSize - referenceOffset; | ||
interpolant.evaluate( referenceTime ); | ||
referenceValue = AnimationUtils.arraySlice( interpolant.resultBuffer, startIndex, endIndex ); | ||
} else { | ||
} | ||
// Interpolate to the reference value | ||
const interpolant = referenceTrack.createInterpolant(); | ||
const startIndex = referenceOffset; | ||
const endIndex = referenceValueSize - referenceOffset; | ||
interpolant.evaluate( referenceTime ); | ||
referenceValue = arraySlice( interpolant.resultBuffer, startIndex, endIndex ); | ||
// Conjugate the quaternion | ||
if ( referenceTrackType === 'quaternion' ) { | ||
} | ||
const referenceQuat = new Quaternion().fromArray( referenceValue ).normalize().conjugate(); | ||
referenceQuat.toArray( referenceValue ); | ||
// Conjugate the quaternion | ||
if ( referenceTrackType === 'quaternion' ) { | ||
} | ||
const referenceQuat = new Quaternion().fromArray( referenceValue ).normalize().conjugate(); | ||
referenceQuat.toArray( referenceValue ); | ||
// Subtract the reference value from all of the track values | ||
} | ||
const numTimes = targetTrack.times.length; | ||
for ( let j = 0; j < numTimes; ++ j ) { | ||
// Subtract the reference value from all of the track values | ||
const valueStart = j * targetValueSize + targetOffset; | ||
const numTimes = targetTrack.times.length; | ||
for ( let j = 0; j < numTimes; ++ j ) { | ||
if ( referenceTrackType === 'quaternion' ) { | ||
const valueStart = j * targetValueSize + targetOffset; | ||
// Multiply the conjugate for quaternion track types | ||
Quaternion.multiplyQuaternionsFlat( | ||
targetTrack.values, | ||
valueStart, | ||
referenceValue, | ||
0, | ||
targetTrack.values, | ||
valueStart | ||
); | ||
if ( referenceTrackType === 'quaternion' ) { | ||
} else { | ||
// Multiply the conjugate for quaternion track types | ||
Quaternion.multiplyQuaternionsFlat( | ||
targetTrack.values, | ||
valueStart, | ||
referenceValue, | ||
0, | ||
targetTrack.values, | ||
valueStart | ||
); | ||
const valueEnd = targetValueSize - targetOffset * 2; | ||
} else { | ||
// Subtract each value for all other numeric track types | ||
for ( let k = 0; k < valueEnd; ++ k ) { | ||
const valueEnd = targetValueSize - targetOffset * 2; | ||
targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; | ||
// Subtract each value for all other numeric track types | ||
for ( let k = 0; k < valueEnd; ++ k ) { | ||
} | ||
targetTrack.values[ valueStart + k ] -= referenceValue[ k ]; | ||
@@ -348,10 +344,19 @@ } | ||
targetClip.blendMode = AdditiveAnimationBlendMode; | ||
} | ||
return targetClip; | ||
targetClip.blendMode = AdditiveAnimationBlendMode; | ||
} | ||
return targetClip; | ||
} | ||
export { | ||
arraySlice, | ||
convertArray, | ||
isTypedArray, | ||
getKeyframeOrder, | ||
sortedArray, | ||
flattenJSON, | ||
subclip, | ||
makeClipAdditive | ||
}; | ||
export { AnimationUtils }; |
@@ -9,3 +9,3 @@ import { | ||
import { DiscreteInterpolant } from '../math/interpolants/DiscreteInterpolant.js'; | ||
import { AnimationUtils } from './AnimationUtils.js'; | ||
import * as AnimationUtils from './AnimationUtils.js'; | ||
@@ -12,0 +12,0 @@ class KeyframeTrack { |
@@ -1,2 +0,2 @@ | ||
export const REVISION = '142'; | ||
export const REVISION = '143'; | ||
export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }; | ||
@@ -3,0 +3,0 @@ export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }; |
@@ -724,3 +724,3 @@ import { Quaternion } from '../math/Quaternion.js'; | ||
if ( this.environment && this.environment.isTexture ) { | ||
if ( this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== true ) { | ||
@@ -727,0 +727,0 @@ object.environment = this.environment.toJSON( meta ).uuid; |
@@ -5,11 +5,3 @@ import { clamp } from '../math/MathUtils.js'; | ||
const { | ||
floatView: _floatView, | ||
uint32View: _uint32View, | ||
baseTable: _baseTable, | ||
shiftTable: _shiftTable, | ||
mantissaTable: _mantissaTable, | ||
exponentTable: _exponentTable, | ||
offsetTable: _offsetTable | ||
} = /*@__PURE__*/ _generateTables(); | ||
const _tables = /*@__PURE__*/ _generateTables(); | ||
@@ -146,3 +138,3 @@ function _generateTables() { | ||
exponentTable: exponentTable, | ||
offsetTable: offsetTable, | ||
offsetTable: offsetTable | ||
}; | ||
@@ -160,6 +152,6 @@ | ||
_floatView[ 0 ] = val; | ||
const f = _uint32View[ 0 ]; | ||
_tables.floatView[ 0 ] = val; | ||
const f = _tables.uint32View[ 0 ]; | ||
const e = ( f >> 23 ) & 0x1ff; | ||
return _baseTable[ e ] + ( ( f & 0x007fffff ) >> _shiftTable[ e ] ); | ||
return _tables.baseTable[ e ] + ( ( f & 0x007fffff ) >> _tables.shiftTable[ e ] ); | ||
@@ -173,4 +165,4 @@ } | ||
const m = val >> 10; | ||
_uint32View[ 0 ] = _mantissaTable[ _offsetTable[ m ] + ( val & 0x3ff ) ] + _exponentTable[ m ]; | ||
return _floatView[ 0 ]; | ||
_tables.uint32View[ 0 ] = _tables.mantissaTable[ _tables.offsetTable[ m ] + ( val & 0x3ff ) ] + _tables.exponentTable[ m ]; | ||
return _tables.floatView[ 0 ]; | ||
@@ -181,3 +173,3 @@ } | ||
toHalfFloat, | ||
fromHalfFloat, | ||
fromHalfFloat | ||
}; |
@@ -11,2 +11,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'CylinderGeometry'; | ||
@@ -13,0 +14,0 @@ |
@@ -17,2 +17,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'EdgesGeometry'; | ||
@@ -19,0 +20,0 @@ |
@@ -75,3 +75,3 @@ /** | ||
const steps = options.steps !== undefined ? options.steps : 1; | ||
let depth = options.depth !== undefined ? options.depth : 1; | ||
const depth = options.depth !== undefined ? options.depth : 1; | ||
@@ -88,11 +88,2 @@ let bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true; | ||
// deprecated options | ||
if ( options.amount !== undefined ) { | ||
console.warn( 'THREE.ExtrudeBufferGeometry: amount has been renamed to depth.' ); | ||
depth = options.amount; | ||
} | ||
// | ||
@@ -99,0 +90,0 @@ |
@@ -9,3 +9,3 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js'; | ||
constructor( points = [ new Vector2( 0, 0.5 ), new Vector2( 0.5, 0 ), new Vector2( 0, - 0.5 ) ], segments = 12, phiStart = 0, phiLength = Math.PI * 2 ) { | ||
constructor( points = [ new Vector2( 0, - 0.5 ), new Vector2( 0.5, 0 ), new Vector2( 0, 0.5 ) ], segments = 12, phiStart = 0, phiLength = Math.PI * 2 ) { | ||
@@ -12,0 +12,0 @@ super(); |
@@ -9,2 +9,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'PlaneGeometry'; | ||
@@ -11,0 +12,0 @@ |
@@ -12,2 +12,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'ShapeGeometry'; | ||
@@ -14,0 +15,0 @@ |
@@ -10,2 +10,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'SphereGeometry'; | ||
@@ -12,0 +13,0 @@ |
@@ -10,2 +10,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'TorusGeometry'; | ||
@@ -12,0 +13,0 @@ |
@@ -10,2 +10,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'TorusKnotGeometry'; | ||
@@ -12,0 +13,0 @@ |
@@ -12,2 +12,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'TubeGeometry'; | ||
@@ -14,0 +15,0 @@ |
@@ -10,2 +10,3 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
super(); | ||
this.type = 'WireframeGeometry'; | ||
@@ -12,0 +13,0 @@ |
@@ -17,2 +17,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
super(); | ||
this.light = light; | ||
@@ -19,0 +20,0 @@ this.light.updateMatrixWorld(); |
@@ -18,2 +18,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
super(); | ||
this.light = light; | ||
@@ -20,0 +21,0 @@ this.light.updateMatrixWorld(); |
@@ -7,3 +7,2 @@ import { Line } from '../objects/Line.js'; | ||
import { BufferGeometry } from '../core/BufferGeometry.js'; | ||
import { FrontSide, BackSide } from '../constants.js'; | ||
@@ -16,3 +15,3 @@ class PlaneHelper extends Line { | ||
const positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ]; | ||
const positions = [ 1, - 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, - 1, 0, 1, 1, 0 ]; | ||
@@ -31,3 +30,3 @@ const geometry = new BufferGeometry(); | ||
const positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ]; | ||
const positions2 = [ 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, - 1, 0, 1, - 1, 0 ]; | ||
@@ -44,12 +43,10 @@ const geometry2 = new BufferGeometry(); | ||
let scale = - this.plane.constant; | ||
this.position.set( 0, 0, 0 ); | ||
if ( Math.abs( scale ) < 1e-8 ) scale = 1e-8; // sign does not matter | ||
this.scale.set( 0.5 * this.size, 0.5 * this.size, 1 ); | ||
this.scale.set( 0.5 * this.size, 0.5 * this.size, scale ); | ||
this.lookAt( this.plane.normal ); | ||
this.children[ 0 ].material.side = ( scale < 0 ) ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here | ||
this.translateZ( - this.plane.constant ); | ||
this.lookAt( this.plane.normal ); | ||
super.updateMatrixWorld( force ); | ||
@@ -56,0 +53,0 @@ |
@@ -15,2 +15,3 @@ import { Vector3 } from '../math/Vector3.js'; | ||
super(); | ||
this.light = light; | ||
@@ -17,0 +18,0 @@ this.light.updateMatrixWorld(); |
@@ -6,2 +6,13 @@ import { Cache } from './Cache.js'; | ||
class HttpError extends Error { | ||
constructor( message, response ) { | ||
super( message ); | ||
this.response = response; | ||
} | ||
} | ||
class FileLoader extends Loader { | ||
@@ -150,3 +161,3 @@ | ||
throw Error( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}` ); | ||
throw new HttpError( `fetch for "${response.url}" responded with ${response.status}: ${response.statusText}`, response ); | ||
@@ -153,0 +164,0 @@ } |
@@ -140,4 +140,4 @@ class LoadingManager { | ||
const DefaultLoadingManager = new LoadingManager(); | ||
const DefaultLoadingManager = /*@__PURE__*/ new LoadingManager(); | ||
export { DefaultLoadingManager, LoadingManager }; |
@@ -1088,11 +1088,2 @@ import { | ||
/* DEPRECATED */ | ||
setTexturePath( value ) { | ||
console.warn( 'THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().' ); | ||
return this.setResourcePath( value ); | ||
} | ||
} | ||
@@ -1099,0 +1090,0 @@ |
import { Material } from './Material.js'; | ||
import { cloneUniforms } from '../renderers/shaders/UniformsUtils.js'; | ||
import { cloneUniforms, cloneUniformsGroups } from '../renderers/shaders/UniformsUtils.js'; | ||
@@ -19,2 +19,3 @@ import default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js'; | ||
this.uniforms = {}; | ||
this.uniformsGroups = []; | ||
@@ -75,2 +76,3 @@ this.vertexShader = default_vertex; | ||
this.uniforms = cloneUniforms( source.uniforms ); | ||
this.uniformsGroups = cloneUniformsGroups( source.uniformsGroups ); | ||
@@ -77,0 +79,0 @@ this.defines = Object.assign( {}, source.defines ); |
@@ -15,8 +15,2 @@ class Matrix3 { | ||
if ( arguments.length > 0 ) { | ||
console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' ); | ||
} | ||
} | ||
@@ -23,0 +17,0 @@ |
@@ -18,8 +18,2 @@ import { Vector3 } from './Vector3.js'; | ||
if ( arguments.length > 0 ) { | ||
console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' ); | ||
} | ||
} | ||
@@ -164,8 +158,2 @@ | ||
if ( ! ( euler && euler.isEuler ) ) { | ||
console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' ); | ||
} | ||
const te = this.elements; | ||
@@ -344,11 +332,4 @@ | ||
multiply( m, n ) { | ||
multiply( m ) { | ||
if ( n !== undefined ) { | ||
console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' ); | ||
return this.multiplyMatrices( m, n ); | ||
} | ||
return this.multiplyMatrices( this, m ); | ||
@@ -779,8 +760,2 @@ | ||
if ( far === undefined ) { | ||
console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' ); | ||
} | ||
const te = this.elements; | ||
@@ -787,0 +762,0 @@ const x = 2 * near / ( right - left ); |
@@ -16,9 +16,2 @@ import * as MathUtils from './MathUtils.js'; | ||
static slerp( qa, qb, qm, t ) { | ||
console.warn( 'THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead.' ); | ||
return qm.slerpQuaternions( qa, qb, t ); | ||
} | ||
static slerpFlat( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) { | ||
@@ -501,11 +494,4 @@ | ||
multiply( q, p ) { | ||
multiply( q ) { | ||
if ( p !== undefined ) { | ||
console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' ); | ||
return this.multiplyQuaternions( q, p ); | ||
} | ||
return this.multiplyQuaternions( this, q ); | ||
@@ -512,0 +498,0 @@ |
@@ -111,11 +111,4 @@ class Vector2 { | ||
add( v, w ) { | ||
add( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); | ||
return this.addVectors( v, w ); | ||
} | ||
this.x += v.x; | ||
@@ -155,11 +148,4 @@ this.y += v.y; | ||
sub( v, w ) { | ||
sub( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); | ||
return this.subVectors( v, w ); | ||
} | ||
this.x -= v.x; | ||
@@ -439,10 +425,4 @@ this.y -= v.y; | ||
fromBufferAttribute( attribute, index, offset ) { | ||
fromBufferAttribute( attribute, index ) { | ||
if ( offset !== undefined ) { | ||
console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' ); | ||
} | ||
this.x = attribute.getX( index ); | ||
@@ -449,0 +429,0 @@ this.y = attribute.getY( index ); |
@@ -106,11 +106,4 @@ import * as MathUtils from './MathUtils.js'; | ||
add( v, w ) { | ||
add( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); | ||
return this.addVectors( v, w ); | ||
} | ||
this.x += v.x; | ||
@@ -154,11 +147,4 @@ this.y += v.y; | ||
sub( v, w ) { | ||
sub( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); | ||
return this.subVectors( v, w ); | ||
} | ||
this.x -= v.x; | ||
@@ -192,11 +178,4 @@ this.y -= v.y; | ||
multiply( v, w ) { | ||
multiply( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' ); | ||
return this.multiplyVectors( v, w ); | ||
} | ||
this.x *= v.x; | ||
@@ -232,8 +211,2 @@ this.y *= v.y; | ||
if ( ! ( euler && euler.isEuler ) ) { | ||
console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); | ||
} | ||
return this.applyQuaternion( _quaternion.setFromEuler( euler ) ); | ||
@@ -507,11 +480,4 @@ | ||
cross( v, w ) { | ||
cross( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' ); | ||
return this.crossVectors( v, w ); | ||
} | ||
return this.crossVectors( this, v ); | ||
@@ -705,10 +671,4 @@ | ||
fromBufferAttribute( attribute, index, offset ) { | ||
fromBufferAttribute( attribute, index ) { | ||
if ( offset !== undefined ) { | ||
console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' ); | ||
} | ||
this.x = attribute.getX( index ); | ||
@@ -715,0 +675,0 @@ this.y = attribute.getY( index ); |
@@ -139,11 +139,4 @@ class Vector4 { | ||
add( v, w ) { | ||
add( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); | ||
return this.addVectors( v, w ); | ||
} | ||
this.x += v.x; | ||
@@ -191,11 +184,4 @@ this.y += v.y; | ||
sub( v, w ) { | ||
sub( v ) { | ||
if ( w !== undefined ) { | ||
console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); | ||
return this.subVectors( v, w ); | ||
} | ||
this.x -= v.x; | ||
@@ -627,10 +613,4 @@ this.y -= v.y; | ||
fromBufferAttribute( attribute, index, offset ) { | ||
fromBufferAttribute( attribute, index ) { | ||
if ( offset !== undefined ) { | ||
console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' ); | ||
} | ||
this.x = attribute.getX( index ); | ||
@@ -637,0 +617,0 @@ this.y = attribute.getY( index ); |
@@ -93,22 +93,22 @@ export default /* glsl */` | ||
vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) { | ||
vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) { | ||
float alpha = pow2( roughness ); // UE4's roughness | ||
float alpha = pow2( roughness ); // UE4's roughness | ||
vec3 halfDir = normalize( lightDir + viewDir ); | ||
vec3 halfDir = normalize( lightDir + viewDir ); | ||
float dotNL = saturate( dot( normal, lightDir ) ); | ||
float dotNV = saturate( dot( normal, viewDir ) ); | ||
float dotNH = saturate( dot( normal, halfDir ) ); | ||
float dotVH = saturate( dot( viewDir, halfDir ) ); | ||
float dotNL = saturate( dot( normal, lightDir ) ); | ||
float dotNV = saturate( dot( normal, viewDir ) ); | ||
float dotNH = saturate( dot( normal, halfDir ) ); | ||
float dotVH = saturate( dot( viewDir, halfDir ) ); | ||
vec3 F = mix(F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence); | ||
vec3 F = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence ); | ||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); | ||
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); | ||
float D = D_GGX( alpha, dotNH ); | ||
float D = D_GGX( alpha, dotNH ); | ||
return F * ( V * D ); | ||
return F * ( V * D ); | ||
} | ||
} | ||
@@ -115,0 +115,0 @@ #endif |
@@ -27,8 +27,6 @@ export default /* glsl */` | ||
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 | ||
vec3 vSigmaX = dFdx( surf_pos.xyz ); | ||
vec3 vSigmaY = dFdy( surf_pos.xyz ); | ||
vec3 vN = surf_norm; // normalized | ||
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); | ||
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); | ||
vec3 vN = surf_norm; // normalized | ||
vec3 R1 = cross( vSigmaY, vN ); | ||
@@ -35,0 +33,0 @@ vec3 R2 = cross( vN, vSigmaX ); |
@@ -20,3 +20,3 @@ export default /* glsl */` | ||
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } | ||
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); } | ||
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } | ||
@@ -92,9 +92,10 @@ // expects values in the range of [0,1]x[0,1], returns values in the [0,1] range. | ||
// https://en.wikipedia.org/wiki/Relative_luminance | ||
float linearToRelativeLuminance( const in vec3 color ) { | ||
float luminance( const in vec3 rgb ) { | ||
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 ); | ||
// assumes rgb is in linear color space with sRGB primaries and D65 white point | ||
return dot( weights, color.rgb ); | ||
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); | ||
return dot( weights, rgb ); | ||
} | ||
@@ -101,0 +102,0 @@ |
@@ -5,104 +5,118 @@ export default /* glsl */` | ||
// XYZ to sRGB color space | ||
const mat3 XYZ_TO_REC709 = mat3( | ||
3.2404542, -0.9692660, 0.0556434, | ||
-1.5371385, 1.8760108, -0.2040259, | ||
-0.4985314, 0.0415560, 1.0572252 | ||
); | ||
// XYZ to linear-sRGB color space | ||
const mat3 XYZ_TO_REC709 = mat3( | ||
3.2404542, -0.9692660, 0.0556434, | ||
-1.5371385, 1.8760108, -0.2040259, | ||
-0.4985314, 0.0415560, 1.0572252 | ||
); | ||
// Assume air interface for top | ||
// Note: We don't handle the case fresnel0 == 1 | ||
vec3 Fresnel0ToIor( vec3 fresnel0 ) { | ||
vec3 sqrtF0 = sqrt( fresnel0 ); | ||
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); | ||
} | ||
// Assume air interface for top | ||
// Note: We don't handle the case fresnel0 == 1 | ||
vec3 Fresnel0ToIor( vec3 fresnel0 ) { | ||
// Conversion FO/IOR | ||
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { | ||
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); | ||
} | ||
vec3 sqrtF0 = sqrt( fresnel0 ); | ||
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); | ||
// ior is a value between 1.0 and 3.0. 1.0 is air interface | ||
float IorToFresnel0( float transmittedIor, float incidentIor ) { | ||
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); | ||
} | ||
} | ||
// Fresnel equations for dielectric/dielectric interfaces. | ||
// Ref: https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html | ||
// Evaluation XYZ sensitivity curves in Fourier space | ||
vec3 evalSensitivity( float OPD, vec3 shift ) { | ||
float phase = 2.0 * PI * OPD * 1.0e-9; | ||
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); | ||
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); | ||
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); | ||
// Conversion FO/IOR | ||
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { | ||
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( -pow2( phase ) * var ); | ||
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[0] ) * exp( -4.5282e+09 * pow2( phase ) ); | ||
xyz /= 1.0685e-7; | ||
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); | ||
vec3 srgb = XYZ_TO_REC709 * xyz; | ||
return srgb; | ||
} | ||
} | ||
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { | ||
vec3 I; | ||
// ior is a value between 1.0 and 3.0. 1.0 is air interface | ||
float IorToFresnel0( float transmittedIor, float incidentIor ) { | ||
// Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0 | ||
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); | ||
// Evaluate the cosTheta on the base layer (Snell law) | ||
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); | ||
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); | ||
// Handle TIR: | ||
float cosTheta2Sq = 1.0 - sinTheta2Sq; | ||
if ( cosTheta2Sq < 0.0 ) { | ||
return vec3( 1.0 ); | ||
} | ||
} | ||
float cosTheta2 = sqrt( cosTheta2Sq ); | ||
// Fresnel equations for dielectric/dielectric interfaces. | ||
// Ref: https://belcour.github.io/blog/research/2017/05/01/brdf-thin-film.html | ||
// Evaluation XYZ sensitivity curves in Fourier space | ||
vec3 evalSensitivity( float OPD, vec3 shift ) { | ||
// First interface | ||
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); | ||
float R12 = F_Schlick( R0, 1.0, cosTheta1 ); | ||
float R21 = R12; | ||
float T121 = 1.0 - R12; | ||
float phi12 = 0.0; | ||
if ( iridescenceIOR < outsideIOR ) phi12 = PI; | ||
float phi21 = PI - phi12; | ||
float phase = 2.0 * PI * OPD * 1.0e-9; | ||
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); | ||
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); | ||
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); | ||
// Second interface | ||
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); // guard against 1.0 | ||
vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); | ||
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); | ||
vec3 phi23 = vec3( 0.0 ); | ||
if ( baseIOR[0] < iridescenceIOR ) phi23[0] = PI; | ||
if ( baseIOR[1] < iridescenceIOR ) phi23[1] = PI; | ||
if ( baseIOR[2] < iridescenceIOR ) phi23[2] = PI; | ||
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); | ||
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); | ||
xyz /= 1.0685e-7; | ||
// Phase shift | ||
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; | ||
vec3 phi = vec3( phi21 ) + phi23; | ||
vec3 rgb = XYZ_TO_REC709 * xyz; | ||
return rgb; | ||
// Compound terms | ||
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); | ||
vec3 r123 = sqrt( R123 ); | ||
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); | ||
} | ||
// Reflectance term for m = 0 (DC term amplitude) | ||
vec3 C0 = R12 + Rs; | ||
I = C0; | ||
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { | ||
// Reflectance term for m > 0 (pairs of diracs) | ||
vec3 Cm = Rs - T121; | ||
for ( int m = 1; m <= 2; ++m ) { | ||
Cm *= r123; | ||
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); | ||
I += Cm * Sm; | ||
} | ||
vec3 I; | ||
// Since out of gamut colors might be produced, negative color values are clamped to 0. | ||
return max( I, vec3( 0.0 ) ); | ||
} | ||
// Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0 | ||
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); | ||
// Evaluate the cosTheta on the base layer (Snell law) | ||
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); | ||
// Handle TIR: | ||
float cosTheta2Sq = 1.0 - sinTheta2Sq; | ||
if ( cosTheta2Sq < 0.0 ) { | ||
return vec3( 1.0 ); | ||
} | ||
float cosTheta2 = sqrt( cosTheta2Sq ); | ||
// First interface | ||
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); | ||
float R12 = F_Schlick( R0, 1.0, cosTheta1 ); | ||
float R21 = R12; | ||
float T121 = 1.0 - R12; | ||
float phi12 = 0.0; | ||
if ( iridescenceIOR < outsideIOR ) phi12 = PI; | ||
float phi21 = PI - phi12; | ||
// Second interface | ||
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); // guard against 1.0 | ||
vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); | ||
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); | ||
vec3 phi23 = vec3( 0.0 ); | ||
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; | ||
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; | ||
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; | ||
// Phase shift | ||
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; | ||
vec3 phi = vec3( phi21 ) + phi23; | ||
// Compound terms | ||
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); | ||
vec3 r123 = sqrt( R123 ); | ||
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); | ||
// Reflectance term for m = 0 (DC term amplitude) | ||
vec3 C0 = R12 + Rs; | ||
I = C0; | ||
// Reflectance term for m > 0 (pairs of diracs) | ||
vec3 Cm = Rs - T121; | ||
for ( int m = 1; m <= 2; ++ m ) { | ||
Cm *= r123; | ||
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); | ||
I += Cm * Sm; | ||
} | ||
// Since out of gamut colors might be produced, negative color values are clamped to 0. | ||
return max( I, vec3( 0.0 ) ); | ||
} | ||
#endif | ||
`; |
@@ -31,22 +31,22 @@ export default /* glsl */` | ||
float dotNVi = saturate( dot( normal, geometry.viewDir ) ); | ||
float dotNVi = saturate( dot( normal, geometry.viewDir ) ); | ||
if ( material.iridescenceThickness == 0.0 ) { | ||
if ( material.iridescenceThickness == 0.0 ) { | ||
material.iridescence = 0.0; | ||
material.iridescence = 0.0; | ||
} else { | ||
} else { | ||
material.iridescence = saturate( material.iridescence ); | ||
material.iridescence = saturate( material.iridescence ); | ||
} | ||
} | ||
if ( material.iridescence > 0.0 ) { | ||
if ( material.iridescence > 0.0 ) { | ||
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); | ||
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); | ||
// Iridescence F0 approximation | ||
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); | ||
// Iridescence F0 approximation | ||
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); | ||
} | ||
} | ||
@@ -53,0 +53,0 @@ #endif |
@@ -22,6 +22,4 @@ export default /* glsl */` | ||
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 | ||
vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); | ||
vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); | ||
vec3 q0 = dFdx( eye_pos.xyz ); | ||
vec3 q1 = dFdy( eye_pos.xyz ); | ||
vec2 st0 = dFdx( vUv.st ); | ||
@@ -28,0 +26,0 @@ vec2 st1 = dFdy( vUv.st ); |
@@ -62,2 +62,16 @@ /** | ||
export function cloneUniformsGroups( src ) { | ||
const dst = []; | ||
for ( let u = 0; u < src.length; u ++ ) { | ||
dst.push( src[ u ].clone() ); | ||
} | ||
return dst; | ||
} | ||
// Legacy | ||
@@ -64,0 +78,0 @@ |
@@ -317,2 +317,5 @@ 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(); | ||
let enabledCapabilities = {}; | ||
@@ -1068,2 +1071,43 @@ | ||
function updateUBOMapping( uniformsGroup, program ) { | ||
let mapping = uboProgamMap.get( program ); | ||
if ( mapping === undefined ) { | ||
mapping = new WeakMap(); | ||
uboProgamMap.set( program, mapping ); | ||
} | ||
let blockIndex = mapping.get( uniformsGroup ); | ||
if ( blockIndex === undefined ) { | ||
blockIndex = gl.getUniformBlockIndex( program, uniformsGroup.name ); | ||
mapping.set( uniformsGroup, blockIndex ); | ||
} | ||
} | ||
function uniformBlockBinding( uniformsGroup, program ) { | ||
const mapping = uboProgamMap.get( program ); | ||
const blockIndex = mapping.get( uniformsGroup ); | ||
if ( uboBindings.get( uniformsGroup ) !== blockIndex ) { | ||
// bind shader specific block index to global block point | ||
gl.uniformBlockBinding( program, blockIndex, uniformsGroup.__bindingPointIndex ); | ||
uboBindings.set( uniformsGroup, blockIndex ); | ||
} | ||
} | ||
// | ||
@@ -1196,2 +1240,5 @@ | ||
updateUBOMapping: updateUBOMapping, | ||
uniformBlockBinding: uniformBlockBinding, | ||
texStorage2D: texStorage2D, | ||
@@ -1198,0 +1245,0 @@ texStorage3D: texStorage3D, |
@@ -47,2 +47,3 @@ import { | ||
import { WebGLMaterials } from './webgl/WebGLMaterials.js'; | ||
import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js'; | ||
import { createElementNS } from '../utils.js'; | ||
@@ -311,3 +312,3 @@ | ||
let utils, bindingStates; | ||
let utils, bindingStates, uniformsGroups; | ||
@@ -343,2 +344,3 @@ function initGLContext() { | ||
shadowMap = new WebGLShadowMap( _this, objects, capabilities ); | ||
uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state ); | ||
@@ -609,2 +611,3 @@ bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities ); | ||
bindingStates.dispose(); | ||
uniformsGroups.dispose(); | ||
programCache.dispose(); | ||
@@ -1790,2 +1793,27 @@ | ||
// UBOs | ||
if ( material.isShaderMaterial || material.isRawShaderMaterial ) { | ||
const groups = material.uniformsGroups; | ||
for ( let i = 0, l = groups.length; i < l; i ++ ) { | ||
if ( capabilities.isWebGL2 ) { | ||
const group = groups[ i ]; | ||
uniformsGroups.update( group, program ); | ||
uniformsGroups.bind( group, program ); | ||
} else { | ||
console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' ); | ||
} | ||
} | ||
} | ||
return program; | ||
@@ -1792,0 +1820,0 @@ |
@@ -88,3 +88,3 @@ import { REVISION } from './constants.js'; | ||
export { KeyframeTrack } from './animation/KeyframeTrack.js'; | ||
export { AnimationUtils } from './animation/AnimationUtils.js'; | ||
export * as AnimationUtils from './animation/AnimationUtils.js'; | ||
export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js'; | ||
@@ -94,2 +94,3 @@ export { AnimationMixer } from './animation/AnimationMixer.js'; | ||
export { Uniform } from './core/Uniform.js'; | ||
export { UniformsGroup } from './core/UniformsGroup.js'; | ||
export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js'; | ||
@@ -96,0 +97,0 @@ export { BufferGeometry } from './core/BufferGeometry.js'; |
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
32916046
1146
418326
84