@needle-tools/three 0.153.1 → 0.154.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/three.cjs +1260 -1517
- package/build/three.js +1267 -1524
- package/build/three.min.js +7 -8
- package/build/three.module.js +859 -1097
- package/build/three.module.min.js +6 -7
- package/examples/jsm/controls/ArcballControls.js +2 -1
- package/examples/jsm/controls/FlyControls.js +25 -9
- package/examples/jsm/controls/OrbitControls.js +7 -1
- package/examples/jsm/csm/CSM.js +1 -1
- package/examples/jsm/effects/AnaglyphEffect.js +1 -1
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/effects/ParallaxBarrierEffect.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +6 -2
- package/examples/jsm/lines/LineMaterial.js +1 -1
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/3MFLoader.js +5 -1
- package/examples/jsm/loaders/AMFLoader.js +5 -1
- package/examples/jsm/loaders/ColladaLoader.js +4 -1
- package/examples/jsm/loaders/FBXLoader.js +9 -2
- package/examples/jsm/loaders/LDrawLoader.js +4 -7
- package/examples/jsm/loaders/PLYLoader.js +16 -6
- package/examples/jsm/loaders/VRMLLoader.js +16 -4
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -2
- package/examples/jsm/math/MeshSurfaceSampler.js +76 -35
- package/examples/jsm/nodes/Nodes.js +20 -15
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +21 -8
- package/examples/jsm/nodes/accessors/CameraNode.js +25 -4
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +7 -1
- package/examples/jsm/nodes/accessors/InstanceNode.js +2 -4
- package/examples/jsm/nodes/accessors/MaterialNode.js +55 -47
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -1
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +3 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +10 -2
- package/examples/jsm/nodes/accessors/SceneNode.js +46 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +43 -62
- package/examples/jsm/nodes/accessors/TangentNode.js +2 -2
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +68 -6
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +1 -1
- package/examples/jsm/nodes/code/CodeNode.js +3 -0
- package/examples/jsm/nodes/code/FunctionNode.js +25 -4
- package/examples/jsm/nodes/core/BypassNode.js +2 -2
- package/examples/jsm/nodes/core/ContextNode.js +2 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/LightingModel.js +2 -1
- package/examples/jsm/nodes/core/Node.js +12 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +24 -5
- package/examples/jsm/nodes/core/PropertyNode.js +4 -0
- package/examples/jsm/nodes/core/StackNode.js +1 -1
- package/examples/jsm/nodes/core/UniformNode.js +1 -1
- package/examples/jsm/nodes/core/VarNode.js +1 -3
- package/examples/jsm/nodes/display/BlendModeNode.js +9 -9
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +7 -7
- package/examples/jsm/nodes/display/ColorSpaceNode.js +50 -49
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -3
- package/examples/jsm/nodes/display/ToneMappingNode.js +8 -8
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -5
- package/examples/jsm/nodes/display/ViewportTextureNode.js +23 -15
- package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +5 -5
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -8
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +4 -4
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +2 -2
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +2 -4
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/examples/jsm/nodes/functions/PhongLightingModel.js +7 -7
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +129 -18
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/examples/jsm/nodes/functions/material/getRoughness.js +3 -3
- package/examples/jsm/nodes/geometry/RangeNode.js +1 -1
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -2
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +91 -62
- package/examples/jsm/nodes/lighting/LightUtils.js +2 -2
- package/examples/jsm/nodes/lighting/LightingContextNode.js +17 -15
- package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
- package/examples/jsm/nodes/lighting/SpotLightNode.js +3 -3
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -15
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +41 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +1 -14
- package/examples/jsm/nodes/materials/NodeMaterial.js +79 -28
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -9
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +3 -3
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +14 -14
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +4 -4
- package/examples/jsm/nodes/math/MathNode.js +6 -0
- package/examples/jsm/nodes/math/OperatorNode.js +1 -1
- package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
- package/examples/jsm/nodes/shadernode/ShaderNode.js +24 -4
- package/examples/jsm/nodes/utils/LoopNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +1 -1
- package/examples/jsm/objects/GroundProjectedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +1 -1
- package/examples/jsm/objects/Refractor.js +1 -1
- package/examples/jsm/objects/Sky.js +1 -1
- package/examples/jsm/objects/Water.js +1 -1
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/offscreen/scene.js +1 -0
- package/examples/jsm/postprocessing/EffectComposer.js +2 -0
- package/examples/jsm/postprocessing/OutlinePass.js +1 -3
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -12
- package/examples/jsm/postprocessing/SavePass.js +3 -1
- package/examples/jsm/postprocessing/TAARenderPass.js +14 -2
- package/examples/jsm/postprocessing/TexturePass.js +2 -1
- package/examples/jsm/postprocessing/UnrealBloomPass.js +9 -10
- package/examples/jsm/renderers/common/Backend.js +2 -0
- package/examples/jsm/renderers/common/Background.js +7 -6
- package/examples/jsm/renderers/common/Pipelines.js +26 -14
- package/examples/jsm/renderers/common/RenderObject.js +18 -0
- package/examples/jsm/renderers/common/RenderObjects.js +29 -29
- package/examples/jsm/renderers/common/Renderer.js +48 -6
- package/examples/jsm/renderers/common/nodes/Nodes.js +1 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +23 -19
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +123 -41
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +29 -9
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +8 -13
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +5 -1
- package/examples/jsm/shaders/BlendShader.js +1 -2
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/CopyShader.js +2 -2
- package/examples/jsm/shaders/ToonShader.js +4 -4
- package/examples/jsm/shaders/WaterRefractionShader.js +1 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +34 -13
- package/package.json +2 -1
- package/src/Three.Legacy.js +0 -228
- package/src/animation/PropertyBinding.js +1 -1
- package/src/constants.js +1 -1
- package/src/core/BufferAttribute.js +0 -24
- package/src/core/BufferGeometry.js +0 -7
- package/src/loaders/Loader.js +2 -0
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/materials/Material.js +3 -0
- package/src/objects/Skeleton.js +0 -2
- package/src/renderers/WebGLRenderer.js +9 -21
- package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +10 -6
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -2
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/points.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +4 -2
- package/src/renderers/webgl/WebGLObjects.js +23 -3
- package/src/renderers/webgl/WebGLProgram.js +24 -5
- package/src/renderers/webgl/WebGLPrograms.js +3 -0
- package/src/renderers/webxr/WebXRManager.js +11 -33
- package/src/scenes/Scene.js +0 -14
- package/examples/jsm/nodes/core/InstanceIndexNode.js +0 -45
- /package/src/renderers/shaders/ShaderChunk/{encodings_fragment.glsl.js → colorspace_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{encodings_pars_fragment.glsl.js → colorspace_pars_fragment.glsl.js} +0 -0
- /package/src/renderers/shaders/ShaderChunk/{output_fragment.glsl.js → opaque_fragment.glsl.js} +0 -0
|
@@ -199,6 +199,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
199
199
|
this.cursorZoom = false; //if wheel zoom should be cursor centered
|
|
200
200
|
this.minFov = 5;
|
|
201
201
|
this.maxFov = 90;
|
|
202
|
+
this.rotateSpeed = 1;
|
|
202
203
|
|
|
203
204
|
this.enabled = true;
|
|
204
205
|
this.enablePan = true;
|
|
@@ -445,7 +446,7 @@ class ArcballControls extends EventDispatcher {
|
|
|
445
446
|
|
|
446
447
|
const distance = this._startCursorPosition.distanceTo( this._currentCursorPosition );
|
|
447
448
|
const angle = this._startCursorPosition.angleTo( this._currentCursorPosition );
|
|
448
|
-
const amount = Math.max( distance / this._tbRadius, angle ); //effective rotation angle
|
|
449
|
+
const amount = Math.max( distance / this._tbRadius, angle ) * this.rotateSpeed; //effective rotation angle
|
|
449
450
|
|
|
450
451
|
this.applyTransformMatrix( this.rotate( this.calculateRotationAxis( this._startCursorPosition, this._currentCursorPosition ), amount ) );
|
|
451
452
|
|
|
@@ -17,6 +17,9 @@ class FlyControls extends EventDispatcher {
|
|
|
17
17
|
|
|
18
18
|
// API
|
|
19
19
|
|
|
20
|
+
// Set to false to disable this control
|
|
21
|
+
this.enabled = true;
|
|
22
|
+
|
|
20
23
|
this.movementSpeed = 1.0;
|
|
21
24
|
this.rollSpeed = 0.005;
|
|
22
25
|
|
|
@@ -44,7 +47,7 @@ class FlyControls extends EventDispatcher {
|
|
|
44
47
|
|
|
45
48
|
this.keydown = function ( event ) {
|
|
46
49
|
|
|
47
|
-
if ( event.altKey ) {
|
|
50
|
+
if ( event.altKey || this.enabled === false ) {
|
|
48
51
|
|
|
49
52
|
return;
|
|
50
53
|
|
|
@@ -82,6 +85,8 @@ class FlyControls extends EventDispatcher {
|
|
|
82
85
|
|
|
83
86
|
this.keyup = function ( event ) {
|
|
84
87
|
|
|
88
|
+
if ( this.enabled === false ) return;
|
|
89
|
+
|
|
85
90
|
switch ( event.code ) {
|
|
86
91
|
|
|
87
92
|
case 'ShiftLeft':
|
|
@@ -114,6 +119,8 @@ class FlyControls extends EventDispatcher {
|
|
|
114
119
|
|
|
115
120
|
this.pointerdown = function ( event ) {
|
|
116
121
|
|
|
122
|
+
if ( this.enabled === false ) return;
|
|
123
|
+
|
|
117
124
|
if ( this.dragToLook ) {
|
|
118
125
|
|
|
119
126
|
this.status ++;
|
|
@@ -135,6 +142,8 @@ class FlyControls extends EventDispatcher {
|
|
|
135
142
|
|
|
136
143
|
this.pointermove = function ( event ) {
|
|
137
144
|
|
|
145
|
+
if ( this.enabled === false ) return;
|
|
146
|
+
|
|
138
147
|
if ( ! this.dragToLook || this.status > 0 ) {
|
|
139
148
|
|
|
140
149
|
const container = this.getContainerDimensions();
|
|
@@ -152,6 +161,8 @@ class FlyControls extends EventDispatcher {
|
|
|
152
161
|
|
|
153
162
|
this.pointerup = function ( event ) {
|
|
154
163
|
|
|
164
|
+
if ( this.enabled === false ) return;
|
|
165
|
+
|
|
155
166
|
if ( this.dragToLook ) {
|
|
156
167
|
|
|
157
168
|
this.status --;
|
|
@@ -175,8 +186,18 @@ class FlyControls extends EventDispatcher {
|
|
|
175
186
|
|
|
176
187
|
};
|
|
177
188
|
|
|
189
|
+
this.contextMenu = function ( event ) {
|
|
190
|
+
|
|
191
|
+
if ( this.enabled === false ) return;
|
|
192
|
+
|
|
193
|
+
event.preventDefault();
|
|
194
|
+
|
|
195
|
+
};
|
|
196
|
+
|
|
178
197
|
this.update = function ( delta ) {
|
|
179
198
|
|
|
199
|
+
if ( this.enabled === false ) return;
|
|
200
|
+
|
|
180
201
|
const moveMult = delta * scope.movementSpeed;
|
|
181
202
|
const rotMult = delta * scope.rollSpeed;
|
|
182
203
|
|
|
@@ -244,7 +265,7 @@ class FlyControls extends EventDispatcher {
|
|
|
244
265
|
|
|
245
266
|
this.dispose = function () {
|
|
246
267
|
|
|
247
|
-
this.domElement.removeEventListener( 'contextmenu',
|
|
268
|
+
this.domElement.removeEventListener( 'contextmenu', _contextmenu );
|
|
248
269
|
this.domElement.removeEventListener( 'pointerdown', _pointerdown );
|
|
249
270
|
this.domElement.removeEventListener( 'pointermove', _pointermove );
|
|
250
271
|
this.domElement.removeEventListener( 'pointerup', _pointerup );
|
|
@@ -254,13 +275,14 @@ class FlyControls extends EventDispatcher {
|
|
|
254
275
|
|
|
255
276
|
};
|
|
256
277
|
|
|
278
|
+
const _contextmenu = this.contextMenu.bind( this );
|
|
257
279
|
const _pointermove = this.pointermove.bind( this );
|
|
258
280
|
const _pointerdown = this.pointerdown.bind( this );
|
|
259
281
|
const _pointerup = this.pointerup.bind( this );
|
|
260
282
|
const _keydown = this.keydown.bind( this );
|
|
261
283
|
const _keyup = this.keyup.bind( this );
|
|
262
284
|
|
|
263
|
-
this.domElement.addEventListener( 'contextmenu',
|
|
285
|
+
this.domElement.addEventListener( 'contextmenu', _contextmenu );
|
|
264
286
|
this.domElement.addEventListener( 'pointerdown', _pointerdown );
|
|
265
287
|
this.domElement.addEventListener( 'pointermove', _pointermove );
|
|
266
288
|
this.domElement.addEventListener( 'pointerup', _pointerup );
|
|
@@ -275,10 +297,4 @@ class FlyControls extends EventDispatcher {
|
|
|
275
297
|
|
|
276
298
|
}
|
|
277
299
|
|
|
278
|
-
function contextmenu( event ) {
|
|
279
|
-
|
|
280
|
-
event.preventDefault();
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
300
|
export { FlyControls };
|
|
@@ -229,9 +229,15 @@ class OrbitControls extends EventDispatcher {
|
|
|
229
229
|
spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );
|
|
230
230
|
|
|
231
231
|
spherical.makeSafe();
|
|
232
|
+
if ( scope.enableDamping ) {
|
|
232
233
|
|
|
234
|
+
currentScale = MathUtils.lerp(currentScale, scale, scope.dampingFactor);
|
|
233
235
|
|
|
234
|
-
|
|
236
|
+
} else {
|
|
237
|
+
|
|
238
|
+
currentScale = scale;
|
|
239
|
+
|
|
240
|
+
}
|
|
235
241
|
|
|
236
242
|
spherical.radius *= currentScale;
|
|
237
243
|
|
package/examples/jsm/csm/CSM.js
CHANGED
|
@@ -32,7 +32,7 @@ export class CSM {
|
|
|
32
32
|
this.shadowMapSize = data.shadowMapSize || 2048;
|
|
33
33
|
this.shadowBias = data.shadowBias || 0.000001;
|
|
34
34
|
this.lightDirection = data.lightDirection || new Vector3( 1, - 1, 1 ).normalize();
|
|
35
|
-
this.lightIntensity = data.lightIntensity ||
|
|
35
|
+
this.lightIntensity = data.lightIntensity || 3;
|
|
36
36
|
this.lightNear = data.lightNear || 1;
|
|
37
37
|
this.lightFar = data.lightFar || 2000;
|
|
38
38
|
this.lightMargin = data.lightMargin || 200;
|
|
@@ -165,7 +165,7 @@ class OutlineEffect {
|
|
|
165
165
|
' gl_FragColor = vec4( outlineColor, outlineAlpha );',
|
|
166
166
|
|
|
167
167
|
' #include <tonemapping_fragment>',
|
|
168
|
-
' #include <
|
|
168
|
+
' #include <colorspace_fragment>',
|
|
169
169
|
' #include <fog_fragment>',
|
|
170
170
|
' #include <premultiplied_alpha_fragment>',
|
|
171
171
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
class RoomEnvironment extends Scene {
|
|
16
16
|
|
|
17
|
-
constructor() {
|
|
17
|
+
constructor( renderer = null ) {
|
|
18
18
|
|
|
19
19
|
super();
|
|
20
20
|
|
|
@@ -24,7 +24,11 @@ class RoomEnvironment extends Scene {
|
|
|
24
24
|
const roomMaterial = new MeshStandardMaterial( { side: BackSide } );
|
|
25
25
|
const boxMaterial = new MeshStandardMaterial();
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
let intensity = 5;
|
|
28
|
+
|
|
29
|
+
if ( renderer !== null && renderer.useLegacyLights === false ) intensity = 900;
|
|
30
|
+
|
|
31
|
+
const mainLight = new PointLight( 0xffffff, intensity, 28, 2 );
|
|
28
32
|
mainLight.position.set( 0.418, 16.199, 0.300 );
|
|
29
33
|
this.add( mainLight );
|
|
30
34
|
|
|
@@ -426,7 +426,7 @@ ShaderLib[ 'line' ] = {
|
|
|
426
426
|
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
427
427
|
|
|
428
428
|
#include <tonemapping_fragment>
|
|
429
|
-
#include <
|
|
429
|
+
#include <colorspace_fragment>
|
|
430
430
|
#include <fog_fragment>
|
|
431
431
|
#include <premultiplied_alpha_fragment>
|
|
432
432
|
|
|
@@ -1067,7 +1067,11 @@ class ThreeMFLoader extends Loader {
|
|
|
1067
1067
|
geometry.setIndex( new BufferAttribute( meshData[ 'triangles' ], 1 ) );
|
|
1068
1068
|
geometry.setAttribute( 'position', new BufferAttribute( meshData[ 'vertices' ], 3 ) );
|
|
1069
1069
|
|
|
1070
|
-
const material = new MeshPhongMaterial( {
|
|
1070
|
+
const material = new MeshPhongMaterial( {
|
|
1071
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1072
|
+
color: 0xffffff,
|
|
1073
|
+
flatShading: true
|
|
1074
|
+
} );
|
|
1071
1075
|
|
|
1072
1076
|
const mesh = new Mesh( geometry, material );
|
|
1073
1077
|
|
|
@@ -432,7 +432,11 @@ class AMFLoader extends Loader {
|
|
|
432
432
|
}
|
|
433
433
|
|
|
434
434
|
const sceneObject = new Group();
|
|
435
|
-
const defaultMaterial = new MeshPhongMaterial( {
|
|
435
|
+
const defaultMaterial = new MeshPhongMaterial( {
|
|
436
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
437
|
+
color: 0xaaaaff,
|
|
438
|
+
flatShading: true
|
|
439
|
+
} );
|
|
436
440
|
|
|
437
441
|
sceneObject.name = amfName;
|
|
438
442
|
sceneObject.userData.author = amfAuthor;
|
|
@@ -3710,7 +3710,10 @@ class ColladaLoader extends Loader {
|
|
|
3710
3710
|
|
|
3711
3711
|
}
|
|
3712
3712
|
|
|
3713
|
-
const fallbackMaterial = new MeshBasicMaterial( {
|
|
3713
|
+
const fallbackMaterial = new MeshBasicMaterial( {
|
|
3714
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
3715
|
+
color: 0xff00ff
|
|
3716
|
+
} );
|
|
3714
3717
|
|
|
3715
3718
|
function resolveMaterialBinding( keys, instanceMaterials ) {
|
|
3716
3719
|
|
|
@@ -1270,7 +1270,10 @@ class FBXTreeParser {
|
|
|
1270
1270
|
|
|
1271
1271
|
} else {
|
|
1272
1272
|
|
|
1273
|
-
material = new MeshPhongMaterial( {
|
|
1273
|
+
material = new MeshPhongMaterial( {
|
|
1274
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1275
|
+
color: 0xcccccc
|
|
1276
|
+
} );
|
|
1274
1277
|
materials.push( material );
|
|
1275
1278
|
|
|
1276
1279
|
}
|
|
@@ -1311,7 +1314,11 @@ class FBXTreeParser {
|
|
|
1311
1314
|
}, null );
|
|
1312
1315
|
|
|
1313
1316
|
// FBX does not list materials for Nurbs lines, so we'll just put our own in here.
|
|
1314
|
-
const material = new LineBasicMaterial( {
|
|
1317
|
+
const material = new LineBasicMaterial( {
|
|
1318
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1319
|
+
color: 0x3300ff,
|
|
1320
|
+
linewidth: 1
|
|
1321
|
+
} );
|
|
1315
1322
|
return new Line( geometry, material );
|
|
1316
1323
|
|
|
1317
1324
|
}
|
|
@@ -133,7 +133,7 @@ class LDrawConditionalLineMaterial extends ShaderMaterial {
|
|
|
133
133
|
outgoingLight = diffuseColor.rgb; // simple shader
|
|
134
134
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
135
135
|
#include <tonemapping_fragment>
|
|
136
|
-
#include <
|
|
136
|
+
#include <colorspace_fragment>
|
|
137
137
|
#include <fog_fragment>
|
|
138
138
|
#include <premultiplied_alpha_fragment>
|
|
139
139
|
}
|
|
@@ -1903,12 +1903,9 @@ class LDrawLoader extends Loader {
|
|
|
1903
1903
|
this.partsLibraryPath = '';
|
|
1904
1904
|
|
|
1905
1905
|
// Material assigned to not available colors for meshes and edges
|
|
1906
|
-
this.missingColorMaterial = new MeshStandardMaterial( { color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
|
|
1907
|
-
this.
|
|
1908
|
-
this.
|
|
1909
|
-
this.missingEdgeColorMaterial.name = 'Missing material - Edge';
|
|
1910
|
-
this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( { fog: true, color: 0xFF00FF } );
|
|
1911
|
-
this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
|
|
1906
|
+
this.missingColorMaterial = new MeshStandardMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
|
|
1907
|
+
this.missingEdgeColorMaterial = new LineBasicMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, color: 0xFF00FF } );
|
|
1908
|
+
this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( { name: Loader.DEFAULT_MATERIAL_NAME, fog: true, color: 0xFF00FF } );
|
|
1912
1909
|
this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
|
|
1913
1910
|
this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
|
|
1914
1911
|
|
|
@@ -104,17 +104,15 @@ class PLYLoader extends Loader {
|
|
|
104
104
|
|
|
105
105
|
parse( data ) {
|
|
106
106
|
|
|
107
|
-
function parseHeader( data ) {
|
|
107
|
+
function parseHeader( data, headerLength = 0 ) {
|
|
108
108
|
|
|
109
109
|
const patternHeader = /^ply([\s\S]*)end_header(\r\n|\r|\n)/;
|
|
110
110
|
let headerText = '';
|
|
111
|
-
let headerLength = 0;
|
|
112
111
|
const result = patternHeader.exec( data );
|
|
113
112
|
|
|
114
113
|
if ( result !== null ) {
|
|
115
114
|
|
|
116
115
|
headerText = result[ 1 ];
|
|
117
|
-
headerLength = new Blob( [ result[ 0 ] ] ).size;
|
|
118
116
|
|
|
119
117
|
}
|
|
120
118
|
|
|
@@ -408,6 +406,12 @@ class PLYLoader extends Loader {
|
|
|
408
406
|
|
|
409
407
|
}
|
|
410
408
|
|
|
409
|
+
if ( buffer.colors.length > 0 ) {
|
|
410
|
+
|
|
411
|
+
geometry.setAttribute( 'color', new Float32BufferAttribute( buffer.colors, 3 ) );
|
|
412
|
+
|
|
413
|
+
}
|
|
414
|
+
|
|
411
415
|
if ( buffer.faceVertexUvs.length > 0 || buffer.faceVertexColors.length > 0 ) {
|
|
412
416
|
|
|
413
417
|
geometry = geometry.toNonIndexed();
|
|
@@ -674,6 +678,9 @@ class PLYLoader extends Loader {
|
|
|
674
678
|
let line = '';
|
|
675
679
|
const lines = [];
|
|
676
680
|
|
|
681
|
+
const startLine = new TextDecoder().decode( bytes.subarray( 0, 5 ) );
|
|
682
|
+
const hasCRNL = /^ply\r\n/.test( startLine );
|
|
683
|
+
|
|
677
684
|
do {
|
|
678
685
|
|
|
679
686
|
const c = String.fromCharCode( bytes[ i ++ ] );
|
|
@@ -696,7 +703,10 @@ class PLYLoader extends Loader {
|
|
|
696
703
|
|
|
697
704
|
} while ( cont && i < bytes.length );
|
|
698
705
|
|
|
699
|
-
|
|
706
|
+
// ascii section using \r\n as line endings
|
|
707
|
+
if ( hasCRNL === true ) i ++;
|
|
708
|
+
|
|
709
|
+
return { headerText: lines.join( '\r' ) + '\r', headerLength: i };
|
|
700
710
|
|
|
701
711
|
}
|
|
702
712
|
|
|
@@ -708,8 +718,8 @@ class PLYLoader extends Loader {
|
|
|
708
718
|
if ( data instanceof ArrayBuffer ) {
|
|
709
719
|
|
|
710
720
|
const bytes = new Uint8Array( data );
|
|
711
|
-
const headerText = extractHeaderText( bytes );
|
|
712
|
-
const header = parseHeader( headerText );
|
|
721
|
+
const { headerText, headerLength } = extractHeaderText( bytes );
|
|
722
|
+
const header = parseHeader( headerText, headerLength );
|
|
713
723
|
|
|
714
724
|
if ( header.format === 'ascii' ) {
|
|
715
725
|
|
|
@@ -960,7 +960,10 @@ class VRMLLoader extends Loader {
|
|
|
960
960
|
|
|
961
961
|
// if the appearance field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
|
|
962
962
|
|
|
963
|
-
let material = new MeshBasicMaterial( {
|
|
963
|
+
let material = new MeshBasicMaterial( {
|
|
964
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
965
|
+
color: 0x000000
|
|
966
|
+
} );
|
|
964
967
|
let geometry;
|
|
965
968
|
|
|
966
969
|
for ( let i = 0, l = fields.length; i < l; i ++ ) {
|
|
@@ -1007,7 +1010,10 @@ class VRMLLoader extends Loader {
|
|
|
1007
1010
|
|
|
1008
1011
|
if ( type === 'points' ) { // points
|
|
1009
1012
|
|
|
1010
|
-
const pointsMaterial = new PointsMaterial( {
|
|
1013
|
+
const pointsMaterial = new PointsMaterial( {
|
|
1014
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1015
|
+
color: 0xffffff
|
|
1016
|
+
} );
|
|
1011
1017
|
|
|
1012
1018
|
if ( geometry.attributes.color !== undefined ) {
|
|
1013
1019
|
|
|
@@ -1029,7 +1035,10 @@ class VRMLLoader extends Loader {
|
|
|
1029
1035
|
|
|
1030
1036
|
} else if ( type === 'line' ) { // lines
|
|
1031
1037
|
|
|
1032
|
-
const lineMaterial = new LineBasicMaterial( {
|
|
1038
|
+
const lineMaterial = new LineBasicMaterial( {
|
|
1039
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1040
|
+
color: 0xffffff
|
|
1041
|
+
} );
|
|
1033
1042
|
|
|
1034
1043
|
if ( geometry.attributes.color !== undefined ) {
|
|
1035
1044
|
|
|
@@ -1116,7 +1125,10 @@ class VRMLLoader extends Loader {
|
|
|
1116
1125
|
|
|
1117
1126
|
// if the material field is NULL or unspecified, lighting is off and the unlit object color is (0, 0, 0)
|
|
1118
1127
|
|
|
1119
|
-
material = new MeshBasicMaterial( {
|
|
1128
|
+
material = new MeshBasicMaterial( {
|
|
1129
|
+
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
1130
|
+
color: 0x000000
|
|
1131
|
+
} );
|
|
1120
1132
|
|
|
1121
1133
|
}
|
|
1122
1134
|
|
|
@@ -288,9 +288,9 @@ const GouraudShader = {
|
|
|
288
288
|
|
|
289
289
|
#include <envmap_fragment>
|
|
290
290
|
|
|
291
|
-
#include <
|
|
291
|
+
#include <opaque_fragment>
|
|
292
292
|
#include <tonemapping_fragment>
|
|
293
|
-
#include <
|
|
293
|
+
#include <colorspace_fragment>
|
|
294
294
|
#include <fog_fragment>
|
|
295
295
|
#include <premultiplied_alpha_fragment>
|
|
296
296
|
#include <dithering_fragment>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Triangle,
|
|
3
|
+
Vector2,
|
|
3
4
|
Vector3
|
|
4
5
|
} from 'three';
|
|
5
6
|
|
|
@@ -16,26 +17,20 @@ import {
|
|
|
16
17
|
|
|
17
18
|
const _face = new Triangle();
|
|
18
19
|
const _color = new Vector3();
|
|
20
|
+
const _uva = new Vector2(), _uvb = new Vector2(), _uvc = new Vector2();
|
|
19
21
|
|
|
20
22
|
class MeshSurfaceSampler {
|
|
21
23
|
|
|
22
24
|
constructor( mesh ) {
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ( geometry.index ) {
|
|
27
|
-
|
|
28
|
-
console.warn( 'THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry.' );
|
|
29
|
-
|
|
30
|
-
geometry = geometry.toNonIndexed();
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
this.geometry = geometry;
|
|
26
|
+
this.geometry = mesh.geometry;
|
|
35
27
|
this.randomFunction = Math.random;
|
|
36
28
|
|
|
29
|
+
this.indexAttribute = this.geometry.index;
|
|
37
30
|
this.positionAttribute = this.geometry.getAttribute( 'position' );
|
|
31
|
+
this.normalAttribute = this.geometry.getAttribute( 'normal' );
|
|
38
32
|
this.colorAttribute = this.geometry.getAttribute( 'color' );
|
|
33
|
+
this.uvAttribute = this.geometry.getAttribute( 'uv' );
|
|
39
34
|
this.weightAttribute = null;
|
|
40
35
|
|
|
41
36
|
this.distribution = null;
|
|
@@ -52,49 +47,62 @@ class MeshSurfaceSampler {
|
|
|
52
47
|
|
|
53
48
|
build() {
|
|
54
49
|
|
|
50
|
+
const indexAttribute = this.indexAttribute;
|
|
55
51
|
const positionAttribute = this.positionAttribute;
|
|
56
52
|
const weightAttribute = this.weightAttribute;
|
|
57
53
|
|
|
58
|
-
const
|
|
54
|
+
const totalFaces = indexAttribute ? ( indexAttribute.count / 3 ) : ( positionAttribute.count / 3 );
|
|
55
|
+
const faceWeights = new Float32Array( totalFaces );
|
|
59
56
|
|
|
60
57
|
// Accumulate weights for each mesh face.
|
|
61
58
|
|
|
62
|
-
for ( let i = 0; i <
|
|
59
|
+
for ( let i = 0; i < totalFaces; i ++ ) {
|
|
63
60
|
|
|
64
61
|
let faceWeight = 1;
|
|
65
62
|
|
|
63
|
+
let i0 = 3 * i;
|
|
64
|
+
let i1 = 3 * i + 1;
|
|
65
|
+
let i2 = 3 * i + 2;
|
|
66
|
+
|
|
67
|
+
if ( indexAttribute ) {
|
|
68
|
+
|
|
69
|
+
i0 = indexAttribute.getX( i0 );
|
|
70
|
+
i1 = indexAttribute.getX( i1 );
|
|
71
|
+
i2 = indexAttribute.getX( i2 );
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
if ( weightAttribute ) {
|
|
67
76
|
|
|
68
|
-
faceWeight = weightAttribute.getX(
|
|
69
|
-
+ weightAttribute.getX(
|
|
70
|
-
+ weightAttribute.getX(
|
|
77
|
+
faceWeight = weightAttribute.getX( i0 )
|
|
78
|
+
+ weightAttribute.getX( i1 )
|
|
79
|
+
+ weightAttribute.getX( i2 );
|
|
71
80
|
|
|
72
81
|
}
|
|
73
82
|
|
|
74
|
-
_face.a.fromBufferAttribute( positionAttribute,
|
|
75
|
-
_face.b.fromBufferAttribute( positionAttribute,
|
|
76
|
-
_face.c.fromBufferAttribute( positionAttribute,
|
|
83
|
+
_face.a.fromBufferAttribute( positionAttribute, i0 );
|
|
84
|
+
_face.b.fromBufferAttribute( positionAttribute, i1 );
|
|
85
|
+
_face.c.fromBufferAttribute( positionAttribute, i2 );
|
|
77
86
|
faceWeight *= _face.getArea();
|
|
78
87
|
|
|
79
|
-
faceWeights[ i
|
|
88
|
+
faceWeights[ i ] = faceWeight;
|
|
80
89
|
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
// Store cumulative total face weights in an array, where weight index
|
|
84
93
|
// corresponds to face index.
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const distribution = new Float32Array( totalFaces );
|
|
88
96
|
let cumulativeTotal = 0;
|
|
89
97
|
|
|
90
|
-
for ( let i = 0; i <
|
|
98
|
+
for ( let i = 0; i < totalFaces; i ++ ) {
|
|
91
99
|
|
|
92
100
|
cumulativeTotal += faceWeights[ i ];
|
|
93
|
-
|
|
94
|
-
this.distribution[ i ] = cumulativeTotal;
|
|
101
|
+
distribution[ i ] = cumulativeTotal;
|
|
95
102
|
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
this.distribution = distribution;
|
|
98
106
|
return this;
|
|
99
107
|
|
|
100
108
|
}
|
|
@@ -106,10 +114,10 @@ class MeshSurfaceSampler {
|
|
|
106
114
|
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
sample( targetPosition, targetNormal, targetColor ) {
|
|
117
|
+
sample( targetPosition, targetNormal, targetColor, targetUV ) {
|
|
110
118
|
|
|
111
119
|
const faceIndex = this.sampleFaceIndex();
|
|
112
|
-
return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor );
|
|
120
|
+
return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor, targetUV );
|
|
113
121
|
|
|
114
122
|
}
|
|
115
123
|
|
|
@@ -154,7 +162,7 @@ class MeshSurfaceSampler {
|
|
|
154
162
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
|
-
sampleFace( faceIndex, targetPosition, targetNormal, targetColor ) {
|
|
165
|
+
sampleFace( faceIndex, targetPosition, targetNormal, targetColor, targetUV ) {
|
|
158
166
|
|
|
159
167
|
let u = this.randomFunction();
|
|
160
168
|
let v = this.randomFunction();
|
|
@@ -166,9 +174,22 @@ class MeshSurfaceSampler {
|
|
|
166
174
|
|
|
167
175
|
}
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
177
|
+
// get the vertex attribute indices
|
|
178
|
+
const indexAttribute = this.indexAttribute;
|
|
179
|
+
let i0 = faceIndex * 3;
|
|
180
|
+
let i1 = faceIndex * 3 + 1;
|
|
181
|
+
let i2 = faceIndex * 3 + 2;
|
|
182
|
+
if ( indexAttribute ) {
|
|
183
|
+
|
|
184
|
+
i0 = indexAttribute.getX( i0 );
|
|
185
|
+
i1 = indexAttribute.getX( i1 );
|
|
186
|
+
i2 = indexAttribute.getX( i2 );
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
_face.a.fromBufferAttribute( this.positionAttribute, i0 );
|
|
191
|
+
_face.b.fromBufferAttribute( this.positionAttribute, i1 );
|
|
192
|
+
_face.c.fromBufferAttribute( this.positionAttribute, i2 );
|
|
172
193
|
|
|
173
194
|
targetPosition
|
|
174
195
|
.set( 0, 0, 0 )
|
|
@@ -178,15 +199,26 @@ class MeshSurfaceSampler {
|
|
|
178
199
|
|
|
179
200
|
if ( targetNormal !== undefined ) {
|
|
180
201
|
|
|
181
|
-
|
|
202
|
+
if ( this.normalAttribute !== undefined ) {
|
|
203
|
+
|
|
204
|
+
_face.a.fromBufferAttribute( this.normalAttribute, i0 );
|
|
205
|
+
_face.b.fromBufferAttribute( this.normalAttribute, i1 );
|
|
206
|
+
_face.c.fromBufferAttribute( this.normalAttribute, i2 );
|
|
207
|
+
targetNormal.set( 0, 0, 0 ).addScaledVector( _face.a, u ).addScaledVector( _face.b, v ).addScaledVector( _face.c, 1 - ( u + v ) ).normalize();
|
|
208
|
+
|
|
209
|
+
} else {
|
|
210
|
+
|
|
211
|
+
_face.getNormal( targetNormal );
|
|
212
|
+
|
|
213
|
+
}
|
|
182
214
|
|
|
183
215
|
}
|
|
184
216
|
|
|
185
217
|
if ( targetColor !== undefined && this.colorAttribute !== undefined ) {
|
|
186
218
|
|
|
187
|
-
_face.a.fromBufferAttribute( this.colorAttribute,
|
|
188
|
-
_face.b.fromBufferAttribute( this.colorAttribute,
|
|
189
|
-
_face.c.fromBufferAttribute( this.colorAttribute,
|
|
219
|
+
_face.a.fromBufferAttribute( this.colorAttribute, i0 );
|
|
220
|
+
_face.b.fromBufferAttribute( this.colorAttribute, i1 );
|
|
221
|
+
_face.c.fromBufferAttribute( this.colorAttribute, i2 );
|
|
190
222
|
|
|
191
223
|
_color
|
|
192
224
|
.set( 0, 0, 0 )
|
|
@@ -200,6 +232,15 @@ class MeshSurfaceSampler {
|
|
|
200
232
|
|
|
201
233
|
}
|
|
202
234
|
|
|
235
|
+
if ( targetUV !== undefined && this.uvAttribute !== undefined ) {
|
|
236
|
+
|
|
237
|
+
_uva.fromBufferAttribute( this.uvAttribute, i0 );
|
|
238
|
+
_uvb.fromBufferAttribute( this.uvAttribute, i1 );
|
|
239
|
+
_uvc.fromBufferAttribute( this.uvAttribute, i2 );
|
|
240
|
+
targetUV.set( 0, 0 ).addScaledVector( _uva, u ).addScaledVector( _uvb, v ).addScaledVector( _uvc, 1 - ( u + v ) );
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
|
|
203
244
|
return this;
|
|
204
245
|
|
|
205
246
|
}
|