super-three 0.160.1 → 0.162.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.
Files changed (225) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +867 -499
  3. package/build/three.module.js +867 -496
  4. package/build/three.module.min.js +1 -1
  5. package/examples/jsm/Addons.js +5 -1
  6. package/examples/jsm/capabilities/WebGPU.js +13 -9
  7. package/examples/jsm/controls/DragControls.js +91 -30
  8. package/examples/jsm/controls/OrbitControls.js +130 -15
  9. package/examples/jsm/controls/TransformControls.js +6 -6
  10. package/examples/jsm/curves/NURBSUtils.js +59 -4
  11. package/examples/jsm/curves/NURBSVolume.js +62 -0
  12. package/examples/jsm/exporters/GLTFExporter.js +11 -1
  13. package/examples/jsm/exporters/USDZExporter.js +8 -7
  14. package/examples/jsm/helpers/TextureHelper.js +3 -3
  15. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  16. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  17. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  18. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  19. package/examples/jsm/libs/tween.module.js +32 -14
  20. package/examples/jsm/loaders/3DMLoader.js +57 -64
  21. package/examples/jsm/loaders/DDSLoader.js +1 -0
  22. package/examples/jsm/loaders/KTX2Loader.js +20 -5
  23. package/examples/jsm/loaders/LUT3dlLoader.js +78 -46
  24. package/examples/jsm/loaders/LUTCubeLoader.js +81 -67
  25. package/examples/jsm/loaders/LUTImageLoader.js +3 -2
  26. package/examples/jsm/loaders/MaterialXLoader.js +115 -16
  27. package/examples/jsm/loaders/SVGLoader.js +4 -3
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +7 -3
  30. package/examples/jsm/materials/MeshPostProcessingMaterial.js +144 -0
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/misc/Timer.js +13 -4
  33. package/examples/jsm/nodes/Nodes.js +24 -11
  34. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  35. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +5 -3
  36. package/examples/jsm/nodes/accessors/CameraNode.js +9 -4
  37. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  38. package/examples/jsm/nodes/accessors/CubeTextureNode.js +12 -1
  39. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  41. package/examples/jsm/nodes/accessors/MorphNode.js +8 -8
  42. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +45 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/TextureStoreNode.js +56 -3
  48. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  49. package/examples/jsm/nodes/accessors/VertexColorNode.js +70 -0
  50. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  51. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  52. package/examples/jsm/nodes/core/AttributeNode.js +1 -1
  53. package/examples/jsm/nodes/core/Node.js +14 -4
  54. package/examples/jsm/nodes/core/NodeBuilder.js +26 -27
  55. package/examples/jsm/nodes/core/NodeFrame.js +18 -10
  56. package/examples/jsm/nodes/core/TempNode.js +1 -1
  57. package/examples/jsm/nodes/core/constants.js +1 -0
  58. package/examples/jsm/nodes/display/AfterImageNode.js +148 -0
  59. package/examples/jsm/nodes/display/AnamorphicNode.js +148 -0
  60. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  61. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +3 -0
  62. package/examples/jsm/nodes/display/GaussianBlurNode.js +33 -13
  63. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  64. package/examples/jsm/nodes/display/PassNode.js +3 -2
  65. package/examples/jsm/nodes/display/ToneMappingNode.js +46 -3
  66. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -4
  67. package/examples/jsm/nodes/display/ViewportNode.js +0 -2
  68. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +4 -4
  69. package/examples/jsm/nodes/fog/FogNode.js +2 -1
  70. package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
  71. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +13 -5
  72. package/examples/jsm/nodes/lighting/LightingContextNode.js +1 -1
  73. package/examples/jsm/nodes/lighting/LightsNode.js +1 -1
  74. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +18 -30
  75. package/examples/jsm/nodes/materials/Materials.js +1 -0
  76. package/examples/jsm/nodes/materials/MeshSSSNodeMaterial.js +84 -0
  77. package/examples/jsm/nodes/materials/NodeMaterial.js +43 -10
  78. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +1 -7
  79. package/examples/jsm/nodes/math/CondNode.js +42 -7
  80. package/examples/jsm/nodes/math/MathNode.js +32 -2
  81. package/examples/jsm/nodes/math/MathUtils.js +15 -0
  82. package/examples/jsm/nodes/math/OperatorNode.js +13 -5
  83. package/examples/jsm/nodes/math/TriNoise3D.js +71 -0
  84. package/examples/jsm/nodes/shadernode/ShaderNode.js +10 -1
  85. package/examples/jsm/nodes/utils/JoinNode.js +2 -2
  86. package/examples/jsm/nodes/utils/LoopNode.js +5 -3
  87. package/examples/jsm/nodes/utils/ReflectorNode.js +227 -0
  88. package/examples/jsm/nodes/utils/RotateNode.js +68 -0
  89. package/examples/jsm/nodes/utils/RotateUVNode.js +1 -9
  90. package/examples/jsm/nodes/utils/SplitNode.js +4 -4
  91. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  92. package/examples/jsm/objects/GroundedSkybox.js +50 -0
  93. package/examples/jsm/objects/QuadMesh.js +8 -2
  94. package/examples/jsm/objects/Water2.js +8 -8
  95. package/examples/jsm/postprocessing/GTAOPass.js +11 -1
  96. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  97. package/examples/jsm/renderers/common/Backend.js +14 -0
  98. package/examples/jsm/renderers/common/Background.js +2 -2
  99. package/examples/jsm/renderers/common/Bindings.js +1 -1
  100. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  101. package/examples/jsm/renderers/common/DataMap.js +1 -1
  102. package/examples/jsm/renderers/common/Info.js +25 -1
  103. package/examples/jsm/renderers/common/Pipelines.js +8 -8
  104. package/examples/jsm/renderers/common/PostProcessing.js +2 -2
  105. package/examples/jsm/renderers/common/ProgrammableStage.js +3 -1
  106. package/examples/jsm/renderers/common/RenderContext.js +2 -0
  107. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  108. package/examples/jsm/renderers/common/RenderObject.js +46 -1
  109. package/examples/jsm/renderers/common/RenderObjects.js +3 -1
  110. package/examples/jsm/renderers/common/Renderer.js +290 -17
  111. package/examples/jsm/renderers/common/StorageBufferAttribute.js +17 -0
  112. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  113. package/examples/jsm/renderers/common/Textures.js +28 -18
  114. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  115. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +2 -1
  116. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  117. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  118. package/examples/jsm/renderers/common/nodes/Nodes.js +5 -2
  119. package/examples/jsm/renderers/webgl/WebGLBackend.js +653 -272
  120. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +171 -39
  121. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +95 -8
  122. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +11 -0
  123. package/examples/jsm/renderers/webgl/utils/WebGLState.js +197 -0
  124. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +424 -11
  125. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -2
  126. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +1 -21
  127. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +2 -2
  128. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +300 -112
  129. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +7 -2
  130. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +71 -79
  131. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -1
  132. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +38 -4
  133. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +87 -14
  134. package/examples/jsm/shaders/OutputShader.js +4 -0
  135. package/examples/jsm/transpiler/AST.js +1 -1
  136. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  137. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  138. package/examples/jsm/transpiler/TSLEncoder.js +1 -1
  139. package/examples/jsm/utils/BufferGeometryUtils.js +23 -27
  140. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  141. package/examples/jsm/utils/SortUtils.js +2 -0
  142. package/examples/jsm/webxr/ARButton.js +12 -2
  143. package/examples/jsm/webxr/VRButton.js +25 -7
  144. package/examples/jsm/webxr/XRButton.js +12 -3
  145. package/examples/jsm/webxr/XRControllerModelFactory.js +14 -1
  146. package/examples/jsm/webxr/XRHandMeshModel.js +3 -1
  147. package/package.json +5 -4
  148. package/src/Three.Legacy.js +20 -0
  149. package/src/Three.js +0 -1
  150. package/src/audio/Audio.js +1 -3
  151. package/src/cameras/PerspectiveCamera.js +35 -0
  152. package/src/constants.js +2 -6
  153. package/src/core/BufferAttribute.js +2 -12
  154. package/src/core/BufferGeometry.js +23 -29
  155. package/src/core/InterleavedBuffer.js +2 -1
  156. package/src/core/InterleavedBufferAttribute.js +20 -0
  157. package/src/core/Object3D.js +11 -0
  158. package/src/core/Raycaster.js +18 -4
  159. package/src/core/RenderTarget.js +44 -21
  160. package/src/extras/PMREMGenerator.js +2 -0
  161. package/src/extras/curves/EllipseCurve.js +2 -2
  162. package/src/helpers/SpotLightHelper.js +18 -1
  163. package/src/loaders/DataTextureLoader.js +0 -4
  164. package/src/loaders/MaterialLoader.js +1 -0
  165. package/src/loaders/ObjectLoader.js +2 -1
  166. package/src/materials/Material.js +2 -1
  167. package/src/materials/MeshBasicMaterial.js +3 -0
  168. package/src/materials/MeshLambertMaterial.js +3 -0
  169. package/src/materials/MeshPhongMaterial.js +3 -0
  170. package/src/materials/MeshStandardMaterial.js +3 -0
  171. package/src/materials/ShaderMaterial.js +2 -1
  172. package/src/math/Quaternion.js +13 -12
  173. package/src/math/Triangle.js +0 -30
  174. package/src/math/Vector3.js +7 -7
  175. package/src/objects/BatchedMesh.js +6 -7
  176. package/src/objects/InstancedMesh.js +53 -0
  177. package/src/objects/Mesh.js +0 -1
  178. package/src/objects/SkinnedMesh.js +0 -8
  179. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  180. package/src/renderers/WebGLRenderer.js +20 -23
  181. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +9 -0
  182. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +56 -11
  183. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  184. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  185. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  186. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  187. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  188. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  189. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +38 -7
  190. package/src/renderers/shaders/ShaderChunk.js +2 -0
  191. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  192. package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -2
  193. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +3 -2
  194. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +2 -1
  195. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -2
  196. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -1
  197. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +2 -2
  198. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +4 -1
  199. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -1
  200. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +2 -1
  201. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -1
  202. package/src/renderers/shaders/ShaderLib/points.glsl.js +2 -1
  203. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  204. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +1 -1
  205. package/src/renderers/shaders/ShaderLib.js +2 -1
  206. package/src/renderers/shaders/UniformsLib.js +1 -0
  207. package/src/renderers/webgl/WebGLAttributes.js +2 -2
  208. package/src/renderers/webgl/WebGLBackground.js +18 -0
  209. package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
  210. package/src/renderers/webgl/WebGLMaterials.js +24 -1
  211. package/src/renderers/webgl/WebGLMorphtargets.js +15 -8
  212. package/src/renderers/webgl/WebGLProgram.js +42 -4
  213. package/src/renderers/webgl/WebGLPrograms.js +38 -27
  214. package/src/renderers/webgl/WebGLState.js +11 -21
  215. package/src/renderers/webgl/WebGLTextures.js +170 -66
  216. package/src/renderers/webxr/WebXRDepthSensing.js +105 -0
  217. package/src/renderers/webxr/WebXRManager.js +46 -0
  218. package/src/scenes/Scene.js +8 -0
  219. package/src/textures/Source.js +1 -0
  220. package/src/textures/Texture.js +1 -29
  221. package/build/three.js +0 -54519
  222. package/build/three.min.js +0 -7
  223. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  224. package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
  225. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -413,18 +413,21 @@ var Tween = /** @class */ (function () {
413
413
  Tween.prototype.isPaused = function () {
414
414
  return this._isPaused;
415
415
  };
416
+ Tween.prototype.getDuration = function () {
417
+ return this._duration;
418
+ };
416
419
  Tween.prototype.to = function (target, duration) {
417
420
  if (duration === void 0) { duration = 1000; }
418
421
  if (this._isPlaying)
419
422
  throw new Error('Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.');
420
423
  this._valuesEnd = target;
421
424
  this._propertiesAreSetUp = false;
422
- this._duration = duration;
425
+ this._duration = duration < 0 ? 0 : duration;
423
426
  return this;
424
427
  };
425
428
  Tween.prototype.duration = function (duration) {
426
429
  if (duration === void 0) { duration = 1000; }
427
- this._duration = duration;
430
+ this._duration = duration < 0 ? 0 : duration;
428
431
  return this;
429
432
  };
430
433
  Tween.prototype.dynamic = function (dynamic) {
@@ -673,12 +676,13 @@ var Tween = /** @class */ (function () {
673
676
  * it is still playing, just paused).
674
677
  */
675
678
  Tween.prototype.update = function (time, autoStart) {
679
+ var _this = this;
680
+ var _a;
676
681
  if (time === void 0) { time = now(); }
677
682
  if (autoStart === void 0) { autoStart = true; }
678
683
  if (this._isPaused)
679
684
  return true;
680
685
  var property;
681
- var elapsed;
682
686
  var endTime = this._startTime + this._duration;
683
687
  if (!this._goToEnd && !this._isPlaying) {
684
688
  if (time > endTime)
@@ -702,18 +706,37 @@ var Tween = /** @class */ (function () {
702
706
  }
703
707
  this._onEveryStartCallbackFired = true;
704
708
  }
705
- elapsed = (time - this._startTime) / this._duration;
706
- elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
709
+ var elapsedTime = time - this._startTime;
710
+ var durationAndDelay = this._duration + ((_a = this._repeatDelayTime) !== null && _a !== void 0 ? _a : this._delayTime);
711
+ var totalTime = this._duration + this._repeat * durationAndDelay;
712
+ var calculateElapsedPortion = function () {
713
+ if (_this._duration === 0)
714
+ return 1;
715
+ if (elapsedTime > totalTime) {
716
+ return 1;
717
+ }
718
+ var timesRepeated = Math.trunc(elapsedTime / durationAndDelay);
719
+ var timeIntoCurrentRepeat = elapsedTime - timesRepeated * durationAndDelay;
720
+ // TODO use %?
721
+ // const timeIntoCurrentRepeat = elapsedTime % durationAndDelay
722
+ var portion = Math.min(timeIntoCurrentRepeat / _this._duration, 1);
723
+ if (portion === 0 && elapsedTime === _this._duration) {
724
+ return 1;
725
+ }
726
+ return portion;
727
+ };
728
+ var elapsed = calculateElapsedPortion();
707
729
  var value = this._easingFunction(elapsed);
708
730
  // properties transformations
709
731
  this._updateProperties(this._object, this._valuesStart, this._valuesEnd, value);
710
732
  if (this._onUpdateCallback) {
711
733
  this._onUpdateCallback(this._object, elapsed);
712
734
  }
713
- if (elapsed === 1) {
735
+ if (this._duration === 0 || elapsedTime >= this._duration) {
714
736
  if (this._repeat > 0) {
737
+ var completeCount = Math.min(Math.trunc((elapsedTime - this._duration) / durationAndDelay) + 1, this._repeat);
715
738
  if (isFinite(this._repeat)) {
716
- this._repeat--;
739
+ this._repeat -= completeCount;
717
740
  }
718
741
  // Reassign starting values, restart by making startTime = now
719
742
  for (property in this._valuesStartRepeat) {
@@ -731,12 +754,7 @@ var Tween = /** @class */ (function () {
731
754
  if (this._yoyo) {
732
755
  this._reversed = !this._reversed;
733
756
  }
734
- if (this._repeatDelayTime !== undefined) {
735
- this._startTime = time + this._repeatDelayTime;
736
- }
737
- else {
738
- this._startTime = time + this._delayTime;
739
- }
757
+ this._startTime += durationAndDelay * completeCount;
740
758
  if (this._onRepeatCallback) {
741
759
  this._onRepeatCallback(this._object);
742
760
  }
@@ -812,7 +830,7 @@ var Tween = /** @class */ (function () {
812
830
  return Tween;
813
831
  }());
814
832
 
815
- var VERSION = '21.0.0';
833
+ var VERSION = '23.1.1';
816
834
 
817
835
  /**
818
836
  * Tween.js - Licensed under the MIT license
@@ -1,29 +1,29 @@
1
1
  import {
2
2
  BufferGeometryLoader,
3
- FileLoader,
4
- Loader,
5
- Object3D,
6
- MeshStandardMaterial,
7
- MeshPhysicalMaterial,
8
- Mesh,
3
+ CanvasTexture,
4
+ ClampToEdgeWrapping,
9
5
  Color,
10
- Points,
11
- PointsMaterial,
6
+ DirectionalLight,
7
+ DoubleSide,
8
+ FileLoader,
9
+ LinearFilter,
12
10
  Line,
13
11
  LineBasicMaterial,
12
+ Loader,
14
13
  Matrix4,
15
- DirectionalLight,
14
+ Mesh,
15
+ MeshPhysicalMaterial,
16
+ MeshStandardMaterial,
17
+ Object3D,
16
18
  PointLight,
17
- SpotLight,
19
+ Points,
20
+ PointsMaterial,
18
21
  RectAreaLight,
22
+ RepeatWrapping,
23
+ SpotLight,
19
24
  Sprite,
20
25
  SpriteMaterial,
21
- CanvasTexture,
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';
@@ -192,6 +192,7 @@ class Rhino3dmLoader extends Loader {
192
192
  mat.color.g = material.color.g;
193
193
  mat.color.b = material.color.b;
194
194
  mat.type = material.type;
195
+ mat.vertexColors = material.vertexColors;
195
196
 
196
197
  const json = JSON.stringify( mat );
197
198
 
@@ -205,6 +206,7 @@ class Rhino3dmLoader extends Loader {
205
206
  _mat.color.g = m.color.g;
206
207
  _mat.color.b = m.color.b;
207
208
  _mat.type = m.type;
209
+ _mat.vertexColors = m.vertexColors;
208
210
 
209
211
  if ( JSON.stringify( _mat ) === json ) {
210
212
 
@@ -235,7 +237,7 @@ class Rhino3dmLoader extends Loader {
235
237
 
236
238
  //console.log(material)
237
239
 
238
- let mat = new MeshPhysicalMaterial( {
240
+ const mat = new MeshPhysicalMaterial( {
239
241
 
240
242
  color: new Color( material.diffuseColor.r / 255.0, material.diffuseColor.g / 255.0, material.diffuseColor.b / 255.0 ),
241
243
  emissive: new Color( material.emissionColor.r, material.emissionColor.g, material.emissionColor.b ),
@@ -256,11 +258,11 @@ class Rhino3dmLoader extends Loader {
256
258
 
257
259
  const pbr = material.pbr;
258
260
 
259
- mat.anisotropy = pbr.anisotropy;
261
+ mat.anisotropy = pbr.anisotropic;
260
262
  mat.anisotropyRotation = pbr.anisotropicRotation;
261
263
  mat.color = new Color( pbr.baseColor.r, pbr.baseColor.g, pbr.baseColor.b );
262
- mat.clearCoat = pbr.clearCoat;
263
- mat.clearCoatRoughness = pbr.clearCoatRoughness;
264
+ mat.clearcoat = pbr.clearcoat;
265
+ mat.clearcoatRoughness = pbr.clearcoatRoughness;
264
266
  mat.metalness = pbr.metallic;
265
267
  mat.transmission = 1 - pbr.opacity;
266
268
  mat.roughness = pbr.roughness;
@@ -310,7 +312,7 @@ class Rhino3dmLoader extends Loader {
310
312
  mat.envMap = map;
311
313
 
312
314
  break;
313
-
315
+
314
316
  case 'Opacity':
315
317
 
316
318
  mat.transmissionMap = map;
@@ -330,7 +332,7 @@ class Rhino3dmLoader extends Loader {
330
332
  mat.transparent = true;
331
333
 
332
334
  break;
333
-
335
+
334
336
  case 'PBR_AmbientOcclusion':
335
337
 
336
338
  mat.aoMap = map;
@@ -461,7 +463,7 @@ class Rhino3dmLoader extends Loader {
461
463
  object.userData.settings[ 'renderSettings' ] = data.renderSettings;
462
464
  object.userData[ 'objectType' ] = 'File3dm';
463
465
  object.userData[ 'materials' ] = null;
464
-
466
+
465
467
  object.name = this.url;
466
468
 
467
469
  let objects = data.objects;
@@ -488,19 +490,16 @@ class Rhino3dmLoader extends Loader {
488
490
 
489
491
  default:
490
492
 
491
- let matId;
493
+ let matId = null;
494
+
495
+ switch ( attributes.materialSource.name ) {
492
496
 
493
- switch( attributes.materialSource.name ) {
494
497
  case 'ObjectMaterialSource_MaterialFromLayer':
495
498
  //check layer index
496
499
  if ( attributes.layerIndex >= 0 ) {
497
500
 
498
501
  matId = data.layers[ attributes.layerIndex ].renderMaterialIndex;
499
502
 
500
- } else {
501
-
502
- matId = null;
503
-
504
503
  }
505
504
 
506
505
  break;
@@ -511,17 +510,13 @@ class Rhino3dmLoader extends Loader {
511
510
 
512
511
  matId = attributes.materialIndex;
513
512
 
514
- } else {
515
-
516
- matId = null;
517
-
518
513
  }
519
514
 
520
515
  break;
521
516
 
522
517
  }
523
518
 
524
- let material;
519
+ let material = null;
525
520
 
526
521
  if ( matId >= 0 ) {
527
522
 
@@ -529,13 +524,8 @@ class Rhino3dmLoader extends Loader {
529
524
  material = this._createMaterial( rMaterial, data.renderEnvironment );
530
525
 
531
526
 
532
- } else {
533
-
534
- material = this._createMaterial();
535
-
536
527
  }
537
528
 
538
- material = this._compareMaterials( material );
539
529
  const _object = this._createObject( obj, material );
540
530
 
541
531
  if ( _object === undefined ) {
@@ -674,19 +664,22 @@ class Rhino3dmLoader extends Loader {
674
664
 
675
665
  geometry = loader.parse( obj.geometry );
676
666
 
677
- if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
678
667
 
679
- mat.vertexColors = true;
668
+ if ( mat === null ) {
669
+
670
+ mat = this._createMaterial();
680
671
 
681
672
  }
682
673
 
683
- if ( mat === null ) {
684
674
 
685
- mat = this._createMaterial();
686
- mat = this._compareMaterials( mat );
675
+ if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
676
+
677
+ mat.vertexColors = true;
687
678
 
688
679
  }
689
680
 
681
+ mat = this._compareMaterials( mat );
682
+
690
683
  const mesh = new Mesh( geometry, mat );
691
684
  mesh.castShadow = attributes.castsShadows;
692
685
  mesh.receiveShadow = attributes.receivesShadows;
@@ -1129,7 +1122,7 @@ function Rhino3dmWorker() {
1129
1122
 
1130
1123
  const _material = doc.materials().get( i );
1131
1124
 
1132
- let material = extractProperties( _material );
1125
+ const material = extractProperties( _material );
1133
1126
 
1134
1127
  const textures = [];
1135
1128
 
@@ -1232,42 +1225,42 @@ function Rhino3dmWorker() {
1232
1225
  // Handle Render Environments for Material Environment
1233
1226
 
1234
1227
  // get the id of the active render environment skylight, which we'll use for environment texture
1235
- const reflectionId = doc.settings().renderSettings().renderEnvironments.reflectionId
1228
+ const reflectionId = doc.settings().renderSettings().renderEnvironments.reflectionId;
1236
1229
 
1237
- const rc = doc.renderContent()
1230
+ const rc = doc.renderContent();
1238
1231
 
1239
- let renderEnvironment = null
1232
+ let renderEnvironment = null;
1240
1233
 
1241
- for( let i = 0; i < rc.count; i++ ) {
1234
+ for ( let i = 0; i < rc.count; i ++ ) {
1242
1235
 
1243
- const content = rc.get(i)
1236
+ const content = rc.get( i );
1244
1237
 
1245
- switch( content.kind ) {
1238
+ switch ( content.kind ) {
1246
1239
 
1247
1240
  case 'environment':
1248
1241
 
1249
- const id = content.id
1242
+ const id = content.id;
1250
1243
 
1251
1244
  // there could be multiple render environments in a 3dm file
1252
1245
  if ( id !== reflectionId ) break;
1253
1246
 
1254
- const renderTexture = content.findChild( 'texture' )
1255
- const fileName = renderTexture.fileName
1247
+ const renderTexture = content.findChild( 'texture' );
1248
+ const fileName = renderTexture.fileName;
1256
1249
 
1257
1250
  for ( let j = 0; j < doc.embeddedFiles().count; j ++ ) {
1258
1251
 
1259
- const _fileName = doc.embeddedFiles().get( j ).fileName
1252
+ const _fileName = doc.embeddedFiles().get( j ).fileName;
1260
1253
 
1261
1254
  if ( fileName === _fileName ) {
1262
1255
 
1263
- const background = doc.getEmbeddedFileAsBase64( fileName )
1264
- const backgroundImage = 'data:image/png;base64,' + background
1256
+ const background = doc.getEmbeddedFileAsBase64( fileName );
1257
+ const backgroundImage = 'data:image/png;base64,' + background;
1265
1258
  renderEnvironment = { type: 'renderEnvironment', image: backgroundImage, name: fileName };
1266
1259
 
1267
1260
  }
1268
1261
 
1269
1262
  }
1270
-
1263
+
1271
1264
  break;
1272
1265
 
1273
1266
  }
@@ -1307,7 +1300,7 @@ function Rhino3dmWorker() {
1307
1300
  renderEnvironments: extractProperties( doc.settings().renderSettings().renderEnvironments ),
1308
1301
  postEffects: extractProperties( doc.settings().renderSettings().postEffects ),
1309
1302
 
1310
- }
1303
+ };
1311
1304
 
1312
1305
  doc.delete();
1313
1306
 
@@ -1317,7 +1310,7 @@ function Rhino3dmWorker() {
1317
1310
 
1318
1311
  function extractTextures( m, tTypes, d ) {
1319
1312
 
1320
- const textures = []
1313
+ const textures = [];
1321
1314
 
1322
1315
  for ( let i = 0; i < tTypes.length; i ++ ) {
1323
1316
 
@@ -1528,7 +1521,7 @@ function Rhino3dmWorker() {
1528
1521
 
1529
1522
  // TODO: precalculate resulting vertices and faces and warn on excessive results
1530
1523
  _geometry.subdivide( 3 );
1531
- mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
1524
+ mesh = rhino.Mesh.createFromSubDControlNet( _geometry, false );
1532
1525
  if ( mesh ) {
1533
1526
 
1534
1527
  geometry = mesh.toThreejsJSON();
@@ -1584,13 +1577,13 @@ function Rhino3dmWorker() {
1584
1577
  if ( _attributes.decals().count > 0 ) {
1585
1578
 
1586
1579
  self.postMessage( { type: 'warning', id: taskID, data: {
1587
- message: `THREE.3DMLoader: No conversion exists for the decals associated with this object.`,
1580
+ message: 'THREE.3DMLoader: No conversion exists for the decals associated with this object.',
1588
1581
  type: 'no conversion',
1589
1582
  guid: _attributes.id
1590
1583
  }
1591
-
1584
+
1592
1585
  } );
1593
-
1586
+
1594
1587
  }
1595
1588
 
1596
1589
  attributes.drawColor = _attributes.drawColor( doc );
@@ -221,6 +221,7 @@ class DDSLoader extends CompressedTextureLoader {
221
221
  }
222
222
 
223
223
  }
224
+
224
225
  break;
225
226
 
226
227
  default:
@@ -120,17 +120,32 @@ class KTX2Loader extends Loader {
120
120
 
121
121
  }
122
122
 
123
+ async detectSupportAsync( renderer ) {
124
+
125
+ this.workerConfig = {
126
+ astcSupported: await renderer.hasFeatureAsync( 'texture-compression-astc' ),
127
+ etc1Supported: await renderer.hasFeatureAsync( 'texture-compression-etc1' ),
128
+ etc2Supported: await renderer.hasFeatureAsync( 'texture-compression-etc2' ),
129
+ dxtSupported: await renderer.hasFeatureAsync( 'texture-compression-bc' ),
130
+ bptcSupported: await renderer.hasFeatureAsync( 'texture-compression-bptc' ),
131
+ pvrtcSupported: await renderer.hasFeatureAsync( 'texture-compression-pvrtc' )
132
+ };
133
+
134
+ return this;
135
+
136
+ }
137
+
123
138
  detectSupport( renderer ) {
124
139
 
125
140
  if ( renderer.isWebGPURenderer === true ) {
126
141
 
127
142
  this.workerConfig = {
128
143
  astcSupported: renderer.hasFeature( 'texture-compression-astc' ),
129
- etc1Supported: false,
144
+ etc1Supported: renderer.hasFeature( 'texture-compression-etc1' ),
130
145
  etc2Supported: renderer.hasFeature( 'texture-compression-etc2' ),
131
146
  dxtSupported: renderer.hasFeature( 'texture-compression-bc' ),
132
- bptcSupported: false,
133
- pvrtcSupported: false
147
+ bptcSupported: renderer.hasFeature( 'texture-compression-bptc' ),
148
+ pvrtcSupported: renderer.hasFeature( 'texture-compression-pvrtc' )
134
149
  };
135
150
 
136
151
  } else {
@@ -865,8 +880,8 @@ async function createRawTexture( container ) {
865
880
  if ( UNCOMPRESSED_FORMATS.has( FORMAT_MAP[ vkFormat ] ) ) {
866
881
 
867
882
  texture = container.pixelDepth === 0
868
- ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
869
- : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
883
+ ? new DataTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight )
884
+ : new Data3DTexture( mipmaps[ 0 ].data, container.pixelWidth, container.pixelHeight, container.pixelDepth );
870
885
 
871
886
  } else {
872
887
 
@@ -1,18 +1,42 @@
1
1
  // http://download.autodesk.com/us/systemdocs/help/2011/lustre/index.html?url=./files/WSc4e151a45a3b785a24c3d9a411df9298473-7ffd.htm,topicNumber=d0e9492
2
2
  // https://community.foundry.com/discuss/topic/103636/format-spec-for-3dl?mode=Post&postID=895258
3
+
3
4
  import {
4
- Loader,
5
- FileLoader,
5
+ ClampToEdgeWrapping,
6
6
  DataTexture,
7
7
  Data3DTexture,
8
+ FileLoader,
9
+ FloatType,
10
+ LinearFilter,
11
+ Loader,
8
12
  RGBAFormat,
9
13
  UnsignedByteType,
10
- ClampToEdgeWrapping,
11
- LinearFilter,
12
14
  } from 'three';
13
15
 
14
16
  export class LUT3dlLoader extends Loader {
15
17
 
18
+ constructor( manager ) {
19
+
20
+ super( manager );
21
+
22
+ this.type = UnsignedByteType;
23
+
24
+ }
25
+
26
+ setType( type ) {
27
+
28
+ if ( type !== UnsignedByteType && type !== FloatType ) {
29
+
30
+ throw new Error( 'LUT3dlLoader: Unsupported type' );
31
+
32
+ }
33
+
34
+ this.type = type;
35
+
36
+ return this;
37
+
38
+ }
39
+
16
40
  load( url, onLoad, onProgress, onError ) {
17
41
 
18
42
  const loader = new FileLoader( this.manager );
@@ -44,80 +68,88 @@ export class LUT3dlLoader extends Loader {
44
68
 
45
69
  }
46
70
 
47
- parse( str ) {
71
+ parse( input ) {
72
+
73
+ const regExpGridInfo = /^[\d ]+$/m;
74
+ const regExpDataPoints = /^([\d.e+-]+) +([\d.e+-]+) +([\d.e+-]+) *$/gm;
48
75
 
49
- // remove empty lines and comment lints
50
- str = str
51
- .replace( /^#.*?(\n|\r)/gm, '' )
52
- .replace( /^\s*?(\n|\r)/gm, '' )
53
- .trim();
76
+ // The first line describes the positions of values on the LUT grid.
77
+ let result = regExpGridInfo.exec( input );
54
78
 
55
- const lines = str.split( /[\n\r]+/g );
79
+ if ( result === null ) {
56
80
 
57
- // first line is the positions on the grid that are provided by the LUT
58
- const gridLines = lines[ 0 ].trim().split( /\s+/g ).map( e => parseFloat( e ) );
81
+ throw new Error( 'LUT3dlLoader: Missing grid information' );
82
+
83
+ }
84
+
85
+ const gridLines = result[ 0 ].trim().split( /\s+/g ).map( Number );
59
86
  const gridStep = gridLines[ 1 ] - gridLines[ 0 ];
60
87
  const size = gridLines.length;
88
+ const sizeSq = size ** 2;
61
89
 
62
- for ( let i = 1, l = gridLines.length; i < l; i ++ ) {
90
+ for ( let i = 1, l = gridLines.length; i < l; ++ i ) {
63
91
 
64
92
  if ( gridStep !== ( gridLines[ i ] - gridLines[ i - 1 ] ) ) {
65
93
 
66
- throw new Error( 'LUT3dlLoader: Inconsistent grid size not supported.' );
94
+ throw new Error( 'LUT3dlLoader: Inconsistent grid size' );
67
95
 
68
96
  }
69
97
 
70
98
  }
71
99
 
72
- const dataArray = new Array( size * size * size * 4 );
100
+ const dataFloat = new Float32Array( size ** 3 * 4 );
101
+ let maxValue = 0.0;
73
102
  let index = 0;
74
- let maxOutputValue = 0.0;
75
- for ( let i = 1, l = lines.length; i < l; i ++ ) {
76
103
 
77
- const line = lines[ i ].trim();
78
- const split = line.split( /\s/g );
104
+ while ( ( result = regExpDataPoints.exec( input ) ) !== null ) {
105
+
106
+ const r = Number( result[ 1 ] );
107
+ const g = Number( result[ 2 ] );
108
+ const b = Number( result[ 3 ] );
79
109
 
80
- const r = parseFloat( split[ 0 ] );
81
- const g = parseFloat( split[ 1 ] );
82
- const b = parseFloat( split[ 2 ] );
83
- maxOutputValue = Math.max( maxOutputValue, r, g, b );
110
+ maxValue = Math.max( maxValue, r, g, b );
84
111
 
85
112
  const bLayer = index % size;
86
113
  const gLayer = Math.floor( index / size ) % size;
87
- const rLayer = Math.floor( index / ( size * size ) ) % size;
114
+ const rLayer = Math.floor( index / ( sizeSq ) ) % size;
88
115
 
89
- // b grows first, then g, then r
90
- const pixelIndex = bLayer * size * size + gLayer * size + rLayer;
91
- dataArray[ 4 * pixelIndex + 0 ] = r;
92
- dataArray[ 4 * pixelIndex + 1 ] = g;
93
- dataArray[ 4 * pixelIndex + 2 ] = b;
94
- dataArray[ 4 * pixelIndex + 3 ] = 1.0;
95
- index += 1;
116
+ // b grows first, then g, then r.
117
+ const d4 = ( bLayer * sizeSq + gLayer * size + rLayer ) * 4;
118
+ dataFloat[ d4 + 0 ] = r;
119
+ dataFloat[ d4 + 1 ] = g;
120
+ dataFloat[ d4 + 2 ] = b;
121
+
122
+ ++ index;
96
123
 
97
124
  }
98
125
 
99
- // Find the apparent bit depth of the stored RGB values and map the
100
- // values to [ 0, 255 ].
101
- const bits = Math.ceil( Math.log2( maxOutputValue ) );
102
- const maxBitValue = Math.pow( 2.0, bits );
103
- for ( let i = 0, l = dataArray.length; i < l; i += 4 ) {
126
+ // Determine the bit depth to scale the values to [0.0, 1.0].
127
+ const bits = Math.ceil( Math.log2( maxValue ) );
128
+ const maxBitValue = Math.pow( 2, bits );
129
+
130
+ const data = this.type === UnsignedByteType ? new Uint8Array( dataFloat.length ) : dataFloat;
131
+ const scale = this.type === UnsignedByteType ? 255 : 1;
132
+
133
+ for ( let i = 0, l = data.length; i < l; i += 4 ) {
134
+
135
+ const i1 = i + 1;
136
+ const i2 = i + 2;
137
+ const i3 = i + 3;
104
138
 
105
- const r = dataArray[ i + 0 ];
106
- const g = dataArray[ i + 1 ];
107
- const b = dataArray[ i + 2 ];
108
- dataArray[ i + 0 ] = 255 * r / maxBitValue; // r
109
- dataArray[ i + 1 ] = 255 * g / maxBitValue; // g
110
- dataArray[ i + 2 ] = 255 * b / maxBitValue; // b
139
+ // Note: data is dataFloat when type is FloatType.
140
+ data[ i ] = dataFloat[ i ] / maxBitValue * scale;
141
+ data[ i1 ] = dataFloat[ i1 ] / maxBitValue * scale;
142
+ data[ i2 ] = dataFloat[ i2 ] / maxBitValue * scale;
143
+ data[ i3 ] = scale;
111
144
 
112
145
  }
113
146
 
114
- const data = new Uint8Array( dataArray );
115
147
  const texture = new DataTexture();
116
148
  texture.image.data = data;
117
149
  texture.image.width = size;
118
150
  texture.image.height = size * size;
119
151
  texture.format = RGBAFormat;
120
- texture.type = UnsignedByteType;
152
+ texture.type = this.type;
121
153
  texture.magFilter = LinearFilter;
122
154
  texture.minFilter = LinearFilter;
123
155
  texture.wrapS = ClampToEdgeWrapping;
@@ -131,7 +163,7 @@ export class LUT3dlLoader extends Loader {
131
163
  texture3D.image.height = size;
132
164
  texture3D.image.depth = size;
133
165
  texture3D.format = RGBAFormat;
134
- texture3D.type = UnsignedByteType;
166
+ texture3D.type = this.type;
135
167
  texture3D.magFilter = LinearFilter;
136
168
  texture3D.minFilter = LinearFilter;
137
169
  texture3D.wrapS = ClampToEdgeWrapping;