super-three 0.160.0 → 0.161.0
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/LICENSE +1 -1
- package/build/three.cjs +380 -109
- package/build/three.module.js +381 -109
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +5 -1
- package/examples/jsm/capabilities/WebGPU.js +13 -9
- package/examples/jsm/controls/OrbitControls.js +102 -13
- package/examples/jsm/curves/NURBSUtils.js +59 -4
- package/examples/jsm/curves/NURBSVolume.js +62 -0
- package/examples/jsm/exporters/USDZExporter.js +8 -7
- package/examples/jsm/helpers/TextureHelper.js +3 -3
- package/examples/jsm/loaders/3DMLoader.js +44 -43
- package/examples/jsm/loaders/DDSLoader.js +1 -0
- package/examples/jsm/loaders/KTX2Loader.js +20 -5
- package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
- package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
- package/examples/jsm/loaders/LUTImageLoader.js +3 -2
- package/examples/jsm/loaders/MaterialXLoader.js +115 -16
- package/examples/jsm/loaders/SVGLoader.js +4 -3
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
- package/examples/jsm/misc/Timer.js +13 -4
- package/examples/jsm/nodes/Nodes.js +16 -5
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
- package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +27 -0
- package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
- package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
- package/examples/jsm/nodes/core/AttributeNode.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +23 -18
- package/examples/jsm/nodes/core/NodeFrame.js +16 -8
- package/examples/jsm/nodes/core/constants.js +1 -0
- package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
- package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
- package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
- package/examples/jsm/nodes/display/PassNode.js +3 -2
- package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
- package/examples/jsm/nodes/display/ViewportNode.js +0 -2
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
- package/examples/jsm/nodes/fog/FogNode.js +2 -1
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
- package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
- package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +6 -4
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
- package/examples/jsm/nodes/math/MathNode.js +12 -2
- package/examples/jsm/nodes/math/MathUtils.js +15 -0
- package/examples/jsm/nodes/math/OperatorNode.js +13 -5
- package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
- package/examples/jsm/nodes/utils/ArrayElementNode.js +6 -0
- package/examples/jsm/nodes/utils/JoinNode.js +2 -2
- package/examples/jsm/nodes/utils/LoopNode.js +3 -3
- package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
- package/examples/jsm/nodes/utils/RotateNode.js +68 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
- package/examples/jsm/nodes/utils/SplitNode.js +4 -4
- package/examples/jsm/objects/GroundedSkybox.js +50 -0
- package/examples/jsm/objects/QuadMesh.js +8 -2
- package/examples/jsm/objects/Water2.js +8 -8
- package/examples/jsm/postprocessing/GTAOPass.js +11 -1
- package/examples/jsm/renderers/common/Backend.js +14 -0
- package/examples/jsm/renderers/common/Bindings.js +1 -1
- package/examples/jsm/renderers/common/DataMap.js +1 -1
- package/examples/jsm/renderers/common/Info.js +25 -1
- package/examples/jsm/renderers/common/Pipelines.js +8 -8
- package/examples/jsm/renderers/common/PostProcessing.js +2 -2
- package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
- package/examples/jsm/renderers/common/RenderObject.js +2 -0
- package/examples/jsm/renderers/common/Renderer.js +238 -22
- package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +25 -5
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
- package/examples/jsm/renderers/common/nodes/Nodes.js +4 -2
- package/examples/jsm/renderers/webgl/WebGLBackend.js +631 -270
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +37 -30
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +89 -8
- package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +377 -11
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +2 -2
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +289 -102
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +56 -39
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +9 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +85 -12
- package/examples/jsm/transpiler/AST.js +1 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
- package/examples/jsm/utils/SortUtils.js +2 -0
- package/examples/jsm/webxr/ARButton.js +12 -2
- package/examples/jsm/webxr/VRButton.js +12 -2
- package/examples/jsm/webxr/XRButton.js +12 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
- package/package.json +2 -2
- package/src/audio/Audio.js +1 -3
- package/src/cameras/PerspectiveCamera.js +35 -0
- package/src/constants.js +1 -2
- package/src/core/BufferAttribute.js +2 -1
- package/src/core/InterleavedBuffer.js +2 -1
- package/src/core/InterleavedBufferAttribute.js +20 -0
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Triangle.js +0 -30
- package/src/objects/BatchedMesh.js +6 -7
- package/src/objects/SkinnedMesh.js +0 -8
- package/src/renderers/WebGLRenderer.js +6 -2
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +15 -7
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -1
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
- package/src/renderers/webgl/WebGLAttributes.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLProgram.js +30 -3
- package/src/renderers/webgl/WebGLPrograms.js +19 -11
- package/src/renderers/webgl/WebGLTextures.js +90 -16
- package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
- package/src/renderers/webxr/WebXRManager.js +46 -0
- package/src/textures/Source.js +1 -0
- package/build/three.js +0 -54519
- package/build/three.min.js +0 -7
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
package/examples/jsm/Addons.js
CHANGED
|
@@ -25,6 +25,7 @@ export * from './csm/CSMShader.js';
|
|
|
25
25
|
export * as Curves from './curves/CurveExtras.js';
|
|
26
26
|
export * from './curves/NURBSCurve.js';
|
|
27
27
|
export * from './curves/NURBSSurface.js';
|
|
28
|
+
export * from './curves/NURBSVolume.js';
|
|
28
29
|
export * as NURBSUtils from './curves/NURBSUtils.js';
|
|
29
30
|
|
|
30
31
|
export * from './effects/AnaglyphEffect.js';
|
|
@@ -151,6 +152,7 @@ export * from './misc/MorphAnimMesh.js';
|
|
|
151
152
|
export * from './misc/MorphBlendMesh.js';
|
|
152
153
|
export * from './misc/ProgressiveLightMap.js';
|
|
153
154
|
export * from './misc/RollerCoaster.js';
|
|
155
|
+
export * from './misc/Timer.js';
|
|
154
156
|
export * from './misc/TubePainter.js';
|
|
155
157
|
export * from './misc/Volume.js';
|
|
156
158
|
export * from './misc/VolumeSlice.js';
|
|
@@ -160,7 +162,7 @@ export * from './modifiers/EdgeSplitModifier.js';
|
|
|
160
162
|
export * from './modifiers/SimplifyModifier.js';
|
|
161
163
|
export * from './modifiers/TessellateModifier.js';
|
|
162
164
|
|
|
163
|
-
export * from './objects/
|
|
165
|
+
export * from './objects/GroundedSkybox.js';
|
|
164
166
|
export * from './objects/Lensflare.js';
|
|
165
167
|
export * from './objects/MarchingCubes.js';
|
|
166
168
|
export * from './objects/Reflector.js';
|
|
@@ -183,6 +185,7 @@ export * from './postprocessing/DotScreenPass.js';
|
|
|
183
185
|
export * from './postprocessing/EffectComposer.js';
|
|
184
186
|
export * from './postprocessing/FilmPass.js';
|
|
185
187
|
export * from './postprocessing/GlitchPass.js';
|
|
188
|
+
export * from './postprocessing/GTAOPass.js';
|
|
186
189
|
export * from './postprocessing/HalftonePass.js';
|
|
187
190
|
export * from './postprocessing/LUTPass.js';
|
|
188
191
|
export * from './postprocessing/MaskPass.js';
|
|
@@ -230,6 +233,7 @@ export * from './shaders/FocusShader.js';
|
|
|
230
233
|
export * from './shaders/FreiChenShader.js';
|
|
231
234
|
export * from './shaders/GammaCorrectionShader.js';
|
|
232
235
|
export * from './shaders/GodRaysShader.js';
|
|
236
|
+
export * from './shaders/GTAOShader.js';
|
|
233
237
|
export * from './shaders/HalftoneShader.js';
|
|
234
238
|
export * from './shaders/HorizontalBlurShader.js';
|
|
235
239
|
export * from './shaders/HorizontalTiltShiftShader.js';
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
if (
|
|
1
|
+
if ( self.GPUShaderStage === undefined ) {
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
self.GPUShaderStage = { VERTEX: 1, FRAGMENT: 2, COMPUTE: 4 };
|
|
4
4
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// statics
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let isAvailable = navigator.gpu !== undefined;
|
|
10
10
|
|
|
11
|
-
const adapter = await navigator.gpu.requestAdapter();
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
if ( typeof window !== 'undefined' && isAvailable ) {
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
14
|
+
isAvailable = await navigator.gpu.requestAdapter();
|
|
18
15
|
|
|
19
16
|
}
|
|
20
17
|
|
|
@@ -22,6 +19,12 @@ class WebGPU {
|
|
|
22
19
|
|
|
23
20
|
static isAvailable() {
|
|
24
21
|
|
|
22
|
+
return Boolean( isAvailable );
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static getStaticAdapter() {
|
|
27
|
+
|
|
25
28
|
return isAvailable;
|
|
26
29
|
|
|
27
30
|
}
|
|
@@ -50,4 +53,5 @@ class WebGPU {
|
|
|
50
53
|
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
|
|
53
57
|
export default WebGPU;
|
|
@@ -374,9 +374,14 @@ class OrbitControls extends EventDispatcher {
|
|
|
374
374
|
|
|
375
375
|
} else if ( scope.object.isOrthographicCamera ) {
|
|
376
376
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
zoomChanged
|
|
377
|
+
zoomChanged = scale !== 1;
|
|
378
|
+
|
|
379
|
+
if ( zoomChanged ) {
|
|
380
|
+
|
|
381
|
+
scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / scale ) );
|
|
382
|
+
scope.object.updateProjectionMatrix();
|
|
383
|
+
|
|
384
|
+
}
|
|
380
385
|
|
|
381
386
|
}
|
|
382
387
|
|
|
@@ -478,6 +483,8 @@ class OrbitControls extends EventDispatcher {
|
|
|
478
483
|
const pointers = [];
|
|
479
484
|
const pointerPositions = {};
|
|
480
485
|
|
|
486
|
+
let controlActive = false;
|
|
487
|
+
|
|
481
488
|
function getAutoRotationAngle( deltaTime ) {
|
|
482
489
|
|
|
483
490
|
if ( deltaTime !== null ) {
|
|
@@ -494,8 +501,8 @@ class OrbitControls extends EventDispatcher {
|
|
|
494
501
|
|
|
495
502
|
function getZoomScale( delta ) {
|
|
496
503
|
|
|
497
|
-
const
|
|
498
|
-
return Math.pow( 0.95, scope.zoomSpeed *
|
|
504
|
+
const normalizedDelta = Math.abs( delta * 0.01 );
|
|
505
|
+
return Math.pow( 0.95, scope.zoomSpeed * normalizedDelta );
|
|
499
506
|
|
|
500
507
|
}
|
|
501
508
|
|
|
@@ -1040,18 +1047,32 @@ class OrbitControls extends EventDispatcher {
|
|
|
1040
1047
|
|
|
1041
1048
|
removePointer( event );
|
|
1042
1049
|
|
|
1043
|
-
|
|
1050
|
+
switch ( pointers.length ) {
|
|
1044
1051
|
|
|
1045
|
-
|
|
1052
|
+
case 0:
|
|
1046
1053
|
|
|
1047
|
-
|
|
1048
|
-
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1054
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
1049
1055
|
|
|
1050
|
-
|
|
1056
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1057
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1051
1058
|
|
|
1052
|
-
|
|
1059
|
+
scope.dispatchEvent( _endEvent );
|
|
1053
1060
|
|
|
1054
|
-
|
|
1061
|
+
state = STATE.NONE;
|
|
1062
|
+
|
|
1063
|
+
break;
|
|
1064
|
+
|
|
1065
|
+
case 1:
|
|
1066
|
+
|
|
1067
|
+
const pointerId = pointers[ 0 ];
|
|
1068
|
+
const position = pointerPositions[ pointerId ];
|
|
1069
|
+
|
|
1070
|
+
// minimal placeholder event - allows state correction on pointer-up
|
|
1071
|
+
onTouchStart( { pointerId: pointerId, pageX: position.x, pageY: position.y } );
|
|
1072
|
+
|
|
1073
|
+
break;
|
|
1074
|
+
|
|
1075
|
+
}
|
|
1055
1076
|
|
|
1056
1077
|
}
|
|
1057
1078
|
|
|
@@ -1192,12 +1213,76 @@ class OrbitControls extends EventDispatcher {
|
|
|
1192
1213
|
|
|
1193
1214
|
scope.dispatchEvent( _startEvent );
|
|
1194
1215
|
|
|
1195
|
-
handleMouseWheel( event );
|
|
1216
|
+
handleMouseWheel( customWheelEvent( event ) );
|
|
1196
1217
|
|
|
1197
1218
|
scope.dispatchEvent( _endEvent );
|
|
1198
1219
|
|
|
1199
1220
|
}
|
|
1200
1221
|
|
|
1222
|
+
function customWheelEvent( event ) {
|
|
1223
|
+
|
|
1224
|
+
const mode = event.deltaMode;
|
|
1225
|
+
|
|
1226
|
+
// minimal wheel event altered to meet delta-zoom demand
|
|
1227
|
+
const newEvent = {
|
|
1228
|
+
clientX: event.clientX,
|
|
1229
|
+
clientY: event.clientY,
|
|
1230
|
+
deltaY: event.deltaY,
|
|
1231
|
+
};
|
|
1232
|
+
|
|
1233
|
+
switch ( mode ) {
|
|
1234
|
+
|
|
1235
|
+
case 1: // LINE_MODE
|
|
1236
|
+
newEvent.deltaY *= 16;
|
|
1237
|
+
break;
|
|
1238
|
+
|
|
1239
|
+
case 2: // PAGE_MODE
|
|
1240
|
+
newEvent.deltaY *= 100;
|
|
1241
|
+
break;
|
|
1242
|
+
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// detect if event was triggered by pinching
|
|
1246
|
+
if ( event.ctrlKey && ! controlActive ) {
|
|
1247
|
+
|
|
1248
|
+
newEvent.deltaY *= 10;
|
|
1249
|
+
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
return newEvent;
|
|
1253
|
+
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
function interceptControlDown( event ) {
|
|
1257
|
+
|
|
1258
|
+
if ( event.key === 'Control' ) {
|
|
1259
|
+
|
|
1260
|
+
controlActive = true;
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
1264
|
+
|
|
1265
|
+
document.addEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
|
|
1266
|
+
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
function interceptControlUp( event ) {
|
|
1272
|
+
|
|
1273
|
+
if ( event.key === 'Control' ) {
|
|
1274
|
+
|
|
1275
|
+
controlActive = false;
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
1279
|
+
|
|
1280
|
+
document.removeEventListener( 'keyup', interceptControlUp, { passive: true, capture: true } );
|
|
1281
|
+
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1201
1286
|
function onKeyDown( event ) {
|
|
1202
1287
|
|
|
1203
1288
|
if ( scope.enabled === false || scope.enablePan === false ) return;
|
|
@@ -1406,6 +1491,10 @@ class OrbitControls extends EventDispatcher {
|
|
|
1406
1491
|
scope.domElement.addEventListener( 'pointercancel', onPointerUp );
|
|
1407
1492
|
scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
1408
1493
|
|
|
1494
|
+
const document = scope.domElement.getRootNode(); // offscreen canvas compatibility
|
|
1495
|
+
|
|
1496
|
+
document.addEventListener( 'keydown', interceptControlDown, { passive: true, capture: true } );
|
|
1497
|
+
|
|
1409
1498
|
// force an update at start
|
|
1410
1499
|
|
|
1411
1500
|
this.update();
|
|
@@ -429,10 +429,10 @@ function calcNURBSDerivatives( p, U, P, u, nd ) {
|
|
|
429
429
|
/*
|
|
430
430
|
Calculate rational B-Spline surface point. See The NURBS Book, page 134, algorithm A4.3.
|
|
431
431
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
P
|
|
435
|
-
u, v
|
|
432
|
+
p, q : degrees of B-Spline surface
|
|
433
|
+
U, V : knot vectors
|
|
434
|
+
P : control points (x, y, z, w)
|
|
435
|
+
u, v : parametric values
|
|
436
436
|
|
|
437
437
|
returns point for given (u, v)
|
|
438
438
|
*/
|
|
@@ -472,6 +472,60 @@ function calcSurfacePoint( p, q, U, V, P, u, v, target ) {
|
|
|
472
472
|
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
/*
|
|
476
|
+
Calculate rational B-Spline volume point. See The NURBS Book, page 134, algorithm A4.3.
|
|
477
|
+
|
|
478
|
+
p, q, r : degrees of B-Splinevolume
|
|
479
|
+
U, V, W : knot vectors
|
|
480
|
+
P : control points (x, y, z, w)
|
|
481
|
+
u, v, w : parametric values
|
|
482
|
+
|
|
483
|
+
returns point for given (u, v, w)
|
|
484
|
+
*/
|
|
485
|
+
function calcVolumePoint( p, q, r, U, V, W, P, u, v, w, target ) {
|
|
486
|
+
|
|
487
|
+
const uspan = findSpan( p, u, U );
|
|
488
|
+
const vspan = findSpan( q, v, V );
|
|
489
|
+
const wspan = findSpan( r, w, W );
|
|
490
|
+
const Nu = calcBasisFunctions( uspan, u, p, U );
|
|
491
|
+
const Nv = calcBasisFunctions( vspan, v, q, V );
|
|
492
|
+
const Nw = calcBasisFunctions( wspan, w, r, W );
|
|
493
|
+
const temp = [];
|
|
494
|
+
|
|
495
|
+
for ( let m = 0; m <= r; ++ m ) {
|
|
496
|
+
|
|
497
|
+
temp[ m ] = [];
|
|
498
|
+
|
|
499
|
+
for ( let l = 0; l <= q; ++ l ) {
|
|
500
|
+
|
|
501
|
+
temp[ m ][ l ] = new Vector4( 0, 0, 0, 0 );
|
|
502
|
+
for ( let k = 0; k <= p; ++ k ) {
|
|
503
|
+
|
|
504
|
+
const point = P[ uspan - p + k ][ vspan - q + l ][ wspan - r + m ].clone();
|
|
505
|
+
const w = point.w;
|
|
506
|
+
point.x *= w;
|
|
507
|
+
point.y *= w;
|
|
508
|
+
point.z *= w;
|
|
509
|
+
temp[ m ][ l ].add( point.multiplyScalar( Nu[ k ] ) );
|
|
510
|
+
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
}
|
|
516
|
+
const Sw = new Vector4( 0, 0, 0, 0 );
|
|
517
|
+
for ( let m = 0; m <= r; ++ m ) {
|
|
518
|
+
for ( let l = 0; l <= q; ++ l ) {
|
|
519
|
+
|
|
520
|
+
Sw.add( temp[ m ][ l ].multiplyScalar( Nw[ m ] ).multiplyScalar( Nv[ l ] ) );
|
|
521
|
+
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
Sw.divideScalar( Sw.w );
|
|
526
|
+
target.set( Sw.x, Sw.y, Sw.z );
|
|
527
|
+
|
|
528
|
+
}
|
|
475
529
|
|
|
476
530
|
|
|
477
531
|
export {
|
|
@@ -484,4 +538,5 @@ export {
|
|
|
484
538
|
calcRationalCurveDerivatives,
|
|
485
539
|
calcNURBSDerivatives,
|
|
486
540
|
calcSurfacePoint,
|
|
541
|
+
calcVolumePoint,
|
|
487
542
|
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Vector4
|
|
3
|
+
} from 'three';
|
|
4
|
+
import * as NURBSUtils from '../curves/NURBSUtils.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* NURBS volume object
|
|
8
|
+
*
|
|
9
|
+
* Implementation is based on (x, y, z [, w=1]]) control points with w=weight.
|
|
10
|
+
**/
|
|
11
|
+
|
|
12
|
+
class NURBSVolume {
|
|
13
|
+
|
|
14
|
+
constructor( degree1, degree2, degree3, knots1, knots2, knots3 /* arrays of reals */, controlPoints /* array^3 of Vector(2|3|4) */ ) {
|
|
15
|
+
|
|
16
|
+
this.degree1 = degree1;
|
|
17
|
+
this.degree2 = degree2;
|
|
18
|
+
this.degree3 = degree3;
|
|
19
|
+
this.knots1 = knots1;
|
|
20
|
+
this.knots2 = knots2;
|
|
21
|
+
this.knots3 = knots3;
|
|
22
|
+
this.controlPoints = [];
|
|
23
|
+
|
|
24
|
+
const len1 = knots1.length - degree1 - 1;
|
|
25
|
+
const len2 = knots2.length - degree2 - 1;
|
|
26
|
+
const len3 = knots3.length - degree3 - 1;
|
|
27
|
+
|
|
28
|
+
// ensure Vector4 for control points
|
|
29
|
+
for ( let i = 0; i < len1; ++ i ) {
|
|
30
|
+
|
|
31
|
+
this.controlPoints[ i ] = [];
|
|
32
|
+
|
|
33
|
+
for ( let j = 0; j < len2; ++ j ) {
|
|
34
|
+
|
|
35
|
+
this.controlPoints[ i ][ j ] = [];
|
|
36
|
+
|
|
37
|
+
for ( let k = 0; k < len3; ++ k ) {
|
|
38
|
+
|
|
39
|
+
const point = controlPoints[ i ][ j ][ k ];
|
|
40
|
+
this.controlPoints[ i ][ j ][ k ] = new Vector4( point.x, point.y, point.z, point.w );
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getPoint( t1, t2, t3, target ) {
|
|
51
|
+
|
|
52
|
+
const u = this.knots1[ 0 ] + t1 * ( this.knots1[ this.knots1.length - 1 ] - this.knots1[ 0 ] ); // linear mapping t1->u
|
|
53
|
+
const v = this.knots2[ 0 ] + t2 * ( this.knots2[ this.knots2.length - 1 ] - this.knots2[ 0 ] ); // linear mapping t2->v
|
|
54
|
+
const w = this.knots3[ 0 ] + t3 * ( this.knots3[ this.knots3.length - 1 ] - this.knots3[ 0 ] ); // linear mapping t3->w
|
|
55
|
+
|
|
56
|
+
NURBSUtils.calcVolumePoint( this.degree1, this.degree2, this.degree3, this.knots1, this.knots2, this.knots3, this.controlPoints, u, v, w, target );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { NURBSVolume };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
NoColorSpace,
|
|
3
|
+
DoubleSide,
|
|
4
4
|
} from 'three';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
strToU8,
|
|
8
|
+
zipSync,
|
|
9
9
|
} from '../libs/fflate.module.js';
|
|
10
10
|
|
|
11
11
|
import { decompress } from './../utils/TextureUtils.js';
|
|
@@ -20,6 +20,7 @@ class USDZExporter {
|
|
|
20
20
|
planeAnchoring: { alignment: 'horizontal' }
|
|
21
21
|
},
|
|
22
22
|
quickLookCompatible: false,
|
|
23
|
+
maxTextureSize: 1024,
|
|
23
24
|
}, options );
|
|
24
25
|
|
|
25
26
|
const files = {};
|
|
@@ -93,7 +94,7 @@ class USDZExporter {
|
|
|
93
94
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
const canvas = imageToCanvas( texture.image, texture.flipY );
|
|
97
|
+
const canvas = imageToCanvas( texture.image, texture.flipY, options.maxTextureSize );
|
|
97
98
|
const blob = await new Promise( resolve => canvas.toBlob( resolve, 'image/png', 1 ) );
|
|
98
99
|
|
|
99
100
|
files[ `textures/Texture_${ id }.png` ] = new Uint8Array( await blob.arrayBuffer() );
|
|
@@ -133,14 +134,14 @@ class USDZExporter {
|
|
|
133
134
|
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
function imageToCanvas( image, flipY ) {
|
|
137
|
+
function imageToCanvas( image, flipY, maxTextureSize ) {
|
|
137
138
|
|
|
138
139
|
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
139
140
|
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
140
141
|
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
|
|
141
142
|
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
142
143
|
|
|
143
|
-
const scale =
|
|
144
|
+
const scale = maxTextureSize / Math.max( image.width, image.height );
|
|
144
145
|
|
|
145
146
|
const canvas = document.createElement( 'canvas' );
|
|
146
147
|
canvas.width = image.width * Math.min( 1, scale );
|
|
@@ -216,8 +216,8 @@ function createSliceGeometry( texture, width, height, depth ) {
|
|
|
216
216
|
const w = sliceCount === 1
|
|
217
217
|
? 1
|
|
218
218
|
: texture.isDataArrayTexture || texture.isCompressedArrayTexture
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
? i
|
|
220
|
+
: i / ( sliceCount - 1 );
|
|
221
221
|
|
|
222
222
|
uvw.setXYZ( j, u, v, w );
|
|
223
223
|
|
|
@@ -234,4 +234,4 @@ function createSliceGeometry( texture, width, height, depth ) {
|
|
|
234
234
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
export { TextureHelper };
|
|
237
|
+
export { TextureHelper };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BufferGeometryLoader,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object3D,
|
|
6
|
-
MeshStandardMaterial,
|
|
7
|
-
MeshPhysicalMaterial,
|
|
8
|
-
Mesh,
|
|
3
|
+
CanvasTexture,
|
|
4
|
+
ClampToEdgeWrapping,
|
|
9
5
|
Color,
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
DirectionalLight,
|
|
7
|
+
DoubleSide,
|
|
8
|
+
FileLoader,
|
|
9
|
+
LinearFilter,
|
|
12
10
|
Line,
|
|
13
11
|
LineBasicMaterial,
|
|
12
|
+
Loader,
|
|
14
13
|
Matrix4,
|
|
15
|
-
|
|
14
|
+
Mesh,
|
|
15
|
+
MeshPhysicalMaterial,
|
|
16
|
+
MeshStandardMaterial,
|
|
17
|
+
Object3D,
|
|
16
18
|
PointLight,
|
|
17
|
-
|
|
19
|
+
Points,
|
|
20
|
+
PointsMaterial,
|
|
18
21
|
RectAreaLight,
|
|
22
|
+
RepeatWrapping,
|
|
23
|
+
SpotLight,
|
|
19
24
|
Sprite,
|
|
20
25
|
SpriteMaterial,
|
|
21
|
-
|
|
22
|
-
LinearFilter,
|
|
23
|
-
ClampToEdgeWrapping,
|
|
24
|
-
RepeatWrapping,
|
|
25
|
-
TextureLoader,
|
|
26
|
-
DoubleSide
|
|
26
|
+
TextureLoader
|
|
27
27
|
} from 'three';
|
|
28
28
|
|
|
29
29
|
import { EXRLoader } from '../loaders/EXRLoader.js';
|
|
@@ -235,7 +235,7 @@ class Rhino3dmLoader extends Loader {
|
|
|
235
235
|
|
|
236
236
|
//console.log(material)
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
const mat = new MeshPhysicalMaterial( {
|
|
239
239
|
|
|
240
240
|
color: new Color( material.diffuseColor.r / 255.0, material.diffuseColor.g / 255.0, material.diffuseColor.b / 255.0 ),
|
|
241
241
|
emissive: new Color( material.emissionColor.r, material.emissionColor.g, material.emissionColor.b ),
|
|
@@ -256,11 +256,11 @@ class Rhino3dmLoader extends Loader {
|
|
|
256
256
|
|
|
257
257
|
const pbr = material.pbr;
|
|
258
258
|
|
|
259
|
-
mat.anisotropy = pbr.
|
|
259
|
+
mat.anisotropy = pbr.anisotropic;
|
|
260
260
|
mat.anisotropyRotation = pbr.anisotropicRotation;
|
|
261
261
|
mat.color = new Color( pbr.baseColor.r, pbr.baseColor.g, pbr.baseColor.b );
|
|
262
|
-
mat.
|
|
263
|
-
mat.
|
|
262
|
+
mat.clearcoat = pbr.clearcoat;
|
|
263
|
+
mat.clearcoatRoughness = pbr.clearcoatRoughness;
|
|
264
264
|
mat.metalness = pbr.metallic;
|
|
265
265
|
mat.transmission = 1 - pbr.opacity;
|
|
266
266
|
mat.roughness = pbr.roughness;
|
|
@@ -310,7 +310,7 @@ class Rhino3dmLoader extends Loader {
|
|
|
310
310
|
mat.envMap = map;
|
|
311
311
|
|
|
312
312
|
break;
|
|
313
|
-
|
|
313
|
+
|
|
314
314
|
case 'Opacity':
|
|
315
315
|
|
|
316
316
|
mat.transmissionMap = map;
|
|
@@ -330,7 +330,7 @@ class Rhino3dmLoader extends Loader {
|
|
|
330
330
|
mat.transparent = true;
|
|
331
331
|
|
|
332
332
|
break;
|
|
333
|
-
|
|
333
|
+
|
|
334
334
|
case 'PBR_AmbientOcclusion':
|
|
335
335
|
|
|
336
336
|
mat.aoMap = map;
|
|
@@ -461,7 +461,7 @@ class Rhino3dmLoader extends Loader {
|
|
|
461
461
|
object.userData.settings[ 'renderSettings' ] = data.renderSettings;
|
|
462
462
|
object.userData[ 'objectType' ] = 'File3dm';
|
|
463
463
|
object.userData[ 'materials' ] = null;
|
|
464
|
-
|
|
464
|
+
|
|
465
465
|
object.name = this.url;
|
|
466
466
|
|
|
467
467
|
let objects = data.objects;
|
|
@@ -490,7 +490,8 @@ class Rhino3dmLoader extends Loader {
|
|
|
490
490
|
|
|
491
491
|
let matId;
|
|
492
492
|
|
|
493
|
-
switch( attributes.materialSource.name ) {
|
|
493
|
+
switch ( attributes.materialSource.name ) {
|
|
494
|
+
|
|
494
495
|
case 'ObjectMaterialSource_MaterialFromLayer':
|
|
495
496
|
//check layer index
|
|
496
497
|
if ( attributes.layerIndex >= 0 ) {
|
|
@@ -1129,7 +1130,7 @@ function Rhino3dmWorker() {
|
|
|
1129
1130
|
|
|
1130
1131
|
const _material = doc.materials().get( i );
|
|
1131
1132
|
|
|
1132
|
-
|
|
1133
|
+
const material = extractProperties( _material );
|
|
1133
1134
|
|
|
1134
1135
|
const textures = [];
|
|
1135
1136
|
|
|
@@ -1232,42 +1233,42 @@ function Rhino3dmWorker() {
|
|
|
1232
1233
|
// Handle Render Environments for Material Environment
|
|
1233
1234
|
|
|
1234
1235
|
// get the id of the active render environment skylight, which we'll use for environment texture
|
|
1235
|
-
const reflectionId = doc.settings().renderSettings().renderEnvironments.reflectionId
|
|
1236
|
+
const reflectionId = doc.settings().renderSettings().renderEnvironments.reflectionId;
|
|
1236
1237
|
|
|
1237
|
-
const rc = doc.renderContent()
|
|
1238
|
+
const rc = doc.renderContent();
|
|
1238
1239
|
|
|
1239
|
-
let renderEnvironment = null
|
|
1240
|
+
let renderEnvironment = null;
|
|
1240
1241
|
|
|
1241
|
-
for( let i = 0; i < rc.count; i++ ) {
|
|
1242
|
+
for ( let i = 0; i < rc.count; i ++ ) {
|
|
1242
1243
|
|
|
1243
|
-
const content = rc.get(i)
|
|
1244
|
+
const content = rc.get( i );
|
|
1244
1245
|
|
|
1245
|
-
switch( content.kind ) {
|
|
1246
|
+
switch ( content.kind ) {
|
|
1246
1247
|
|
|
1247
1248
|
case 'environment':
|
|
1248
1249
|
|
|
1249
|
-
const id = content.id
|
|
1250
|
+
const id = content.id;
|
|
1250
1251
|
|
|
1251
1252
|
// there could be multiple render environments in a 3dm file
|
|
1252
1253
|
if ( id !== reflectionId ) break;
|
|
1253
1254
|
|
|
1254
|
-
const renderTexture = content.findChild( 'texture' )
|
|
1255
|
-
const fileName = renderTexture.fileName
|
|
1255
|
+
const renderTexture = content.findChild( 'texture' );
|
|
1256
|
+
const fileName = renderTexture.fileName;
|
|
1256
1257
|
|
|
1257
1258
|
for ( let j = 0; j < doc.embeddedFiles().count; j ++ ) {
|
|
1258
1259
|
|
|
1259
|
-
const _fileName = doc.embeddedFiles().get( j ).fileName
|
|
1260
|
+
const _fileName = doc.embeddedFiles().get( j ).fileName;
|
|
1260
1261
|
|
|
1261
1262
|
if ( fileName === _fileName ) {
|
|
1262
1263
|
|
|
1263
|
-
const background = doc.getEmbeddedFileAsBase64( fileName )
|
|
1264
|
-
const backgroundImage = 'data:image/png;base64,' + background
|
|
1264
|
+
const background = doc.getEmbeddedFileAsBase64( fileName );
|
|
1265
|
+
const backgroundImage = 'data:image/png;base64,' + background;
|
|
1265
1266
|
renderEnvironment = { type: 'renderEnvironment', image: backgroundImage, name: fileName };
|
|
1266
1267
|
|
|
1267
1268
|
}
|
|
1268
1269
|
|
|
1269
1270
|
}
|
|
1270
|
-
|
|
1271
|
+
|
|
1271
1272
|
break;
|
|
1272
1273
|
|
|
1273
1274
|
}
|
|
@@ -1307,7 +1308,7 @@ function Rhino3dmWorker() {
|
|
|
1307
1308
|
renderEnvironments: extractProperties( doc.settings().renderSettings().renderEnvironments ),
|
|
1308
1309
|
postEffects: extractProperties( doc.settings().renderSettings().postEffects ),
|
|
1309
1310
|
|
|
1310
|
-
}
|
|
1311
|
+
};
|
|
1311
1312
|
|
|
1312
1313
|
doc.delete();
|
|
1313
1314
|
|
|
@@ -1317,7 +1318,7 @@ function Rhino3dmWorker() {
|
|
|
1317
1318
|
|
|
1318
1319
|
function extractTextures( m, tTypes, d ) {
|
|
1319
1320
|
|
|
1320
|
-
const textures = []
|
|
1321
|
+
const textures = [];
|
|
1321
1322
|
|
|
1322
1323
|
for ( let i = 0; i < tTypes.length; i ++ ) {
|
|
1323
1324
|
|
|
@@ -1584,13 +1585,13 @@ function Rhino3dmWorker() {
|
|
|
1584
1585
|
if ( _attributes.decals().count > 0 ) {
|
|
1585
1586
|
|
|
1586
1587
|
self.postMessage( { type: 'warning', id: taskID, data: {
|
|
1587
|
-
message:
|
|
1588
|
+
message: 'THREE.3DMLoader: No conversion exists for the decals associated with this object.',
|
|
1588
1589
|
type: 'no conversion',
|
|
1589
1590
|
guid: _attributes.id
|
|
1590
1591
|
}
|
|
1591
|
-
|
|
1592
|
+
|
|
1592
1593
|
} );
|
|
1593
|
-
|
|
1594
|
+
|
|
1594
1595
|
}
|
|
1595
1596
|
|
|
1596
1597
|
attributes.drawColor = _attributes.drawColor( doc );
|