opal-js_wrap-three 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (503) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +4 -4
  4. data/lib/opal/js_wrap/three/version.rb +1 -1
  5. data/lib-opal/js_wrap/three/WebGL.js +102 -0
  6. data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
  7. data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
  8. data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
  9. data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
  10. data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
  11. data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
  12. data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
  13. data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
  14. data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
  15. data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
  16. data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
  17. data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
  18. data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
  19. data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
  20. data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
  21. data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
  22. data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
  23. data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
  24. data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
  25. data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
  26. data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
  27. data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
  28. data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
  29. data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
  30. data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
  31. data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
  32. data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
  33. data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
  34. data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
  35. data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
  36. data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
  37. data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
  38. data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
  39. data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
  40. data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
  41. data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
  42. data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
  43. data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
  44. data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
  45. data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
  46. data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
  47. data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
  48. data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
  49. data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
  50. data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
  51. data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
  52. data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
  53. data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
  54. data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
  55. data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
  56. data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
  57. data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
  58. data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
  59. data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
  60. data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
  61. data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
  62. data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
  63. data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
  64. data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
  65. data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
  66. data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
  67. data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
  68. data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
  69. data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
  70. data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
  71. data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
  72. data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
  73. data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
  74. data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
  75. data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
  76. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
  77. data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
  78. data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
  79. data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
  80. data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
  81. data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
  82. data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
  83. data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
  84. data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
  85. data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
  86. data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
  87. data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
  88. data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
  89. data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
  90. data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
  91. data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
  92. data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
  93. data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
  94. data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
  95. data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
  96. data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
  97. data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
  98. data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
  99. data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
  100. data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
  101. data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
  102. data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
  103. data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
  104. data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
  105. data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
  106. data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
  107. data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
  108. data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
  109. data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
  110. data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
  111. data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
  112. data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
  113. data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
  114. data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
  115. data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
  116. data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
  117. data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
  118. data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
  119. data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
  120. data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
  121. data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
  122. data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
  123. data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
  124. data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
  125. data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
  126. data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
  127. data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
  128. data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
  129. data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
  130. data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
  131. data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
  132. data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
  133. data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
  134. data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
  135. data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
  136. data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
  137. data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
  138. data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
  139. data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
  140. data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
  141. data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
  142. data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
  143. data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
  144. data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
  145. data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
  146. data/lib-opal/js_wrap/three/math/Lut.js +170 -0
  147. data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
  148. data/lib-opal/js_wrap/three/math/OBB.js +345 -0
  149. data/lib-opal/js_wrap/three/math/Octree.js +409 -0
  150. data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
  151. data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
  152. data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
  153. data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
  154. data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
  155. data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
  156. data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
  157. data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
  158. data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
  159. data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
  160. data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
  161. data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
  162. data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
  163. data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
  164. data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
  165. data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
  166. data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
  167. data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
  168. data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
  169. data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
  170. data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
  171. data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
  172. data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
  173. data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
  174. data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
  175. data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
  176. data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
  177. data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
  178. data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
  179. data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
  180. data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
  181. data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
  182. data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
  183. data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
  184. data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
  185. data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
  186. data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
  187. data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
  188. data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
  189. data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
  190. data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
  191. data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
  192. data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
  193. data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
  194. data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
  195. data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
  196. data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
  197. data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
  198. data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
  199. data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
  200. data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
  201. data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
  202. data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
  203. data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
  204. data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
  205. data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
  206. data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
  207. data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
  208. data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
  209. data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
  210. data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
  211. data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
  212. data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
  213. data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
  214. data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
  215. data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
  216. data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
  217. data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
  218. data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
  219. data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
  220. data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
  221. data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
  222. data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
  223. data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
  224. data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
  225. data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
  226. data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
  227. data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
  228. data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
  229. data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
  230. data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
  231. data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
  232. data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
  233. data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
  234. data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
  235. data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
  236. data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
  237. data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
  238. data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
  239. data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
  240. data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
  241. data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
  242. data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
  243. data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
  244. data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
  245. data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
  246. data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
  247. data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
  248. data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
  249. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
  250. data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
  251. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
  252. data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
  253. data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
  254. data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
  255. data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
  256. data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
  257. data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
  258. data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
  259. data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
  260. data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
  261. data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
  262. data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
  263. data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
  264. data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
  265. data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
  266. data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
  267. data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
  268. data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
  269. data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
  270. data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
  271. data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
  272. data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
  273. data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
  274. data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
  275. data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
  276. data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
  277. data/lib-opal/js_wrap/three/objects/Water.js +246 -0
  278. data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
  279. data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
  280. data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
  281. data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
  282. data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
  283. data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
  284. data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
  285. data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
  286. data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
  287. data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
  288. data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
  289. data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
  290. data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
  291. data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
  292. data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
  293. data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
  294. data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
  295. data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
  296. data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
  297. data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
  298. data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
  299. data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
  300. data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
  301. data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
  302. data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
  303. data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
  304. data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
  305. data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
  306. data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
  307. data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
  308. data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
  309. data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
  310. data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
  311. data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
  312. data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
  313. data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
  314. data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
  315. data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
  316. data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
  317. data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
  318. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
  319. data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
  320. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
  321. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
  322. data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
  323. data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
  324. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
  325. data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
  326. data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
  327. data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
  328. data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
  329. data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
  330. data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
  331. data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
  332. data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
  333. data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
  334. data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
  335. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
  336. data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
  337. data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
  338. data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
  339. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
  340. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
  341. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
  342. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
  343. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
  344. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
  345. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
  346. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
  347. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
  348. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
  349. data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
  350. data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
  351. data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
  352. data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
  353. data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
  354. data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
  355. data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
  356. data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
  357. data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
  358. data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
  359. data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
  360. data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
  361. data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
  362. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
  363. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
  364. data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
  365. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
  366. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
  367. data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
  368. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
  369. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
  370. data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
  371. data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
  372. data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
  373. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
  374. data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
  375. data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
  376. data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
  377. data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
  378. data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
  379. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
  380. data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
  381. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
  382. data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
  383. data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
  384. data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
  385. data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
  386. data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
  387. data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
  388. data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
  389. data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
  390. data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
  391. data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
  392. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
  393. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
  394. data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
  395. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
  396. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
  397. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
  398. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
  399. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
  400. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
  401. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
  402. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
  403. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
  404. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
  405. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
  406. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
  407. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
  408. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
  409. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
  410. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
  411. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
  412. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
  413. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
  414. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
  415. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
  416. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
  417. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
  418. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
  419. data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
  420. data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
  421. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
  422. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
  423. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
  424. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
  425. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
  426. data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
  427. data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
  428. data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
  429. data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
  430. data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
  431. data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
  432. data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
  433. data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
  434. data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
  435. data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
  436. data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
  437. data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
  438. data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
  439. data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
  440. data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
  441. data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
  442. data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
  443. data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
  444. data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
  445. data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
  446. data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
  447. data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
  448. data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
  449. data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
  450. data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
  451. data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
  452. data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
  453. data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
  454. data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
  455. data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
  456. data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
  457. data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
  458. data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
  459. data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
  460. data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
  461. data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
  462. data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
  463. data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
  464. data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
  465. data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
  466. data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
  467. data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
  468. data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
  469. data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
  470. data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
  471. data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
  472. data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
  473. data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
  474. data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
  475. data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
  476. data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
  477. data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
  478. data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
  479. data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
  480. data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
  481. data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
  482. data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
  483. data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
  484. data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
  485. data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
  486. data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
  487. data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
  488. data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
  489. data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
  490. data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
  491. data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
  492. data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
  493. data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
  494. data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
  495. data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
  496. data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
  497. data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
  498. data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
  499. data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
  500. data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
  501. data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
  502. data/opal-js_wrap-three.gemspec +4 -4
  503. metadata +502 -5
@@ -0,0 +1,931 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports", "three", "./LWO2Parser.js", "./LWO3Parser.js"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports, require("three"), require("./LWO2Parser.js"), require("./LWO3Parser.js"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports, global.three, global.LWO2Parser, global.LWO3Parser);
11
+ global.IFFParser = mod.exports;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three, _LWO2Parser, _LWO3Parser) {
14
+ "use strict";
15
+
16
+ Object.defineProperty(_exports, "__esModule", {
17
+ value: true
18
+ });
19
+ _exports.IFFParser = IFFParser;
20
+
21
+ /**
22
+ * === IFFParser ===
23
+ * - Parses data from the IFF buffer.
24
+ * - LWO3 files are in IFF format and can contain the following data types, referred to by shorthand codes
25
+ *
26
+ * ATOMIC DATA TYPES
27
+ * ID Tag - 4x 7 bit uppercase ASCII chars: ID4
28
+ * signed integer, 1, 2, or 4 byte length: I1, I2, I4
29
+ * unsigned integer, 1, 2, or 4 byte length: U1, U2, U4
30
+ * float, 4 byte length: F4
31
+ * string, series of ASCII chars followed by null byte (If the length of the string including the null terminating byte is odd, an extra null is added so that the data that follows will begin on an even byte boundary): S0
32
+ *
33
+ * COMPOUND DATA TYPES
34
+ * Variable-length Index (index into an array or collection): U2 or U4 : VX
35
+ * Color (RGB): F4 + F4 + F4: COL12
36
+ * Coordinate (x, y, z): F4 + F4 + F4: VEC12
37
+ * Percentage F4 data type from 0->1 with 1 = 100%: FP4
38
+ * Angle in radian F4: ANG4
39
+ * Filename (string) S0: FNAM0
40
+ * XValue F4 + index (VX) + optional envelope( ENVL ): XVAL
41
+ * XValue vector VEC12 + index (VX) + optional envelope( ENVL ): XVAL3
42
+ *
43
+ * The IFF file is arranged in chunks:
44
+ * CHUNK = ID4 + length (U4) + length X bytes of data + optional 0 pad byte
45
+ * optional 0 pad byte is there to ensure chunk ends on even boundary, not counted in size
46
+ *
47
+ * COMPOUND DATA TYPES
48
+ * - Chunks are combined in Forms (collections of chunks)
49
+ * - FORM = string 'FORM' (ID4) + length (U4) + type (ID4) + optional ( CHUNK | FORM )
50
+ * - CHUNKS and FORMS are collectively referred to as blocks
51
+ * - The entire file is contained in one top level FORM
52
+ *
53
+ **/
54
+ function IFFParser() {
55
+ this.debugger = new Debugger(); // this.debugger.enable(); // un-comment to log IFF hierarchy.
56
+ }
57
+
58
+ IFFParser.prototype = {
59
+ constructor: IFFParser,
60
+ parse: function parse(buffer) {
61
+ this.reader = new DataViewReader(buffer);
62
+ this.tree = {
63
+ materials: {},
64
+ layers: [],
65
+ tags: [],
66
+ textures: []
67
+ }; // start out at the top level to add any data before first layer is encountered
68
+
69
+ this.currentLayer = this.tree;
70
+ this.currentForm = this.tree;
71
+ this.parseTopForm();
72
+ if (this.tree.format === undefined) return;
73
+
74
+ if (this.tree.format === 'LWO2') {
75
+ this.parser = new _LWO2Parser.LWO2Parser(this);
76
+
77
+ while (!this.reader.endOfFile()) {
78
+ this.parser.parseBlock();
79
+ }
80
+ } else if (this.tree.format === 'LWO3') {
81
+ this.parser = new _LWO3Parser.LWO3Parser(this);
82
+
83
+ while (!this.reader.endOfFile()) {
84
+ this.parser.parseBlock();
85
+ }
86
+ }
87
+
88
+ this.debugger.offset = this.reader.offset;
89
+ this.debugger.closeForms();
90
+ return this.tree;
91
+ },
92
+ parseTopForm: function parseTopForm() {
93
+ this.debugger.offset = this.reader.offset;
94
+ var topForm = this.reader.getIDTag();
95
+
96
+ if (topForm !== 'FORM') {
97
+ console.warn('LWOLoader: Top-level FORM missing.');
98
+ return;
99
+ }
100
+
101
+ var length = this.reader.getUint32();
102
+ this.debugger.dataOffset = this.reader.offset;
103
+ this.debugger.length = length;
104
+ var type = this.reader.getIDTag();
105
+
106
+ if (type === 'LWO2') {
107
+ this.tree.format = type;
108
+ } else if (type === 'LWO3') {
109
+ this.tree.format = type;
110
+ }
111
+
112
+ this.debugger.node = 0;
113
+ this.debugger.nodeID = type;
114
+ this.debugger.log();
115
+ return;
116
+ },
117
+ ///
118
+ // FORM PARSING METHODS
119
+ ///
120
+ // Forms are organisational and can contain any number of sub chunks and sub forms
121
+ // FORM ::= 'FORM'[ID4], length[U4], type[ID4], ( chunk[CHUNK] | form[FORM] ) * }
122
+ parseForm: function parseForm(length) {
123
+ var type = this.reader.getIDTag();
124
+
125
+ switch (type) {
126
+ // SKIPPED FORMS
127
+ // if skipForm( length ) is called, the entire form and any sub forms and chunks are skipped
128
+ case 'ISEQ': // Image sequence
129
+
130
+ case 'ANIM': // plug in animation
131
+
132
+ case 'STCC': // Color-cycling Still
133
+
134
+ case 'VPVL':
135
+ case 'VPRM':
136
+ case 'NROT':
137
+ case 'WRPW': // image wrap w ( for cylindrical and spherical projections)
138
+
139
+ case 'WRPH': // image wrap h
140
+
141
+ case 'FUNC':
142
+ case 'FALL':
143
+ case 'OPAC':
144
+ case 'GRAD': // gradient texture
145
+
146
+ case 'ENVS':
147
+ case 'VMOP':
148
+ case 'VMBG': // Car Material FORMS
149
+
150
+ case 'OMAX':
151
+ case 'STEX':
152
+ case 'CKBG':
153
+ case 'CKEY':
154
+ case 'VMLA':
155
+ case 'VMLB':
156
+ this.debugger.skipped = true;
157
+ this.skipForm(length); // not currently supported
158
+
159
+ break;
160
+ // if break; is called directly, the position in the lwoTree is not created
161
+ // any sub chunks and forms are added to the parent form instead
162
+
163
+ case 'META':
164
+ case 'NNDS':
165
+ case 'NODS':
166
+ case 'NDTA':
167
+ case 'ADAT':
168
+ case 'AOVS':
169
+ case 'BLOK': // used by texture nodes
170
+
171
+ case 'IBGC': // imageBackgroundColor
172
+
173
+ case 'IOPC': // imageOpacity
174
+
175
+ case 'IIMG': // hold reference to image path
176
+
177
+ case 'TXTR':
178
+ // this.setupForm( type, length );
179
+ this.debugger.length = 4;
180
+ this.debugger.skipped = true;
181
+ break;
182
+
183
+ case 'IFAL': // imageFallof
184
+
185
+ case 'ISCL': // imageScale
186
+
187
+ case 'IPOS': // imagePosition
188
+
189
+ case 'IROT': // imageRotation
190
+
191
+ case 'IBMP':
192
+ case 'IUTD':
193
+ case 'IVTD':
194
+ this.parseTextureNodeAttribute(type);
195
+ break;
196
+
197
+ case 'ENVL':
198
+ this.parseEnvelope(length);
199
+ break;
200
+ // CLIP FORM AND SUB FORMS
201
+
202
+ case 'CLIP':
203
+ if (this.tree.format === 'LWO2') {
204
+ this.parseForm(length);
205
+ } else {
206
+ this.parseClip(length);
207
+ }
208
+
209
+ break;
210
+
211
+ case 'STIL':
212
+ this.parseImage();
213
+ break;
214
+
215
+ case 'XREF':
216
+ // clone of another STIL
217
+ this.reader.skip(8); // unknown
218
+
219
+ this.currentForm.referenceTexture = {
220
+ index: this.reader.getUint32(),
221
+ refName: this.reader.getString() // internal unique ref
222
+
223
+ };
224
+ break;
225
+ // Not in spec, used by texture nodes
226
+
227
+ case 'IMST':
228
+ this.parseImageStateForm(length);
229
+ break;
230
+ // SURF FORM AND SUB FORMS
231
+
232
+ case 'SURF':
233
+ this.parseSurfaceForm(length);
234
+ break;
235
+
236
+ case 'VALU':
237
+ // Not in spec
238
+ this.parseValueForm(length);
239
+ break;
240
+
241
+ case 'NTAG':
242
+ this.parseSubNode(length);
243
+ break;
244
+
245
+ case 'ATTR': // BSDF Node Attributes
246
+
247
+ case 'SATR':
248
+ // Standard Node Attributes
249
+ this.setupForm('attributes', length);
250
+ break;
251
+
252
+ case 'NCON':
253
+ this.parseConnections(length);
254
+ break;
255
+
256
+ case 'SSHA':
257
+ this.parentForm = this.currentForm;
258
+ this.currentForm = this.currentSurface;
259
+ this.setupForm('surfaceShader', length);
260
+ break;
261
+
262
+ case 'SSHD':
263
+ this.setupForm('surfaceShaderData', length);
264
+ break;
265
+
266
+ case 'ENTR':
267
+ // Not in spec
268
+ this.parseEntryForm(length);
269
+ break;
270
+ // Image Map Layer
271
+
272
+ case 'IMAP':
273
+ this.parseImageMap(length);
274
+ break;
275
+
276
+ case 'TAMP':
277
+ this.parseXVAL('amplitude', length);
278
+ break;
279
+ //Texture Mapping Form
280
+
281
+ case 'TMAP':
282
+ this.setupForm('textureMap', length);
283
+ break;
284
+
285
+ case 'CNTR':
286
+ this.parseXVAL3('center', length);
287
+ break;
288
+
289
+ case 'SIZE':
290
+ this.parseXVAL3('scale', length);
291
+ break;
292
+
293
+ case 'ROTA':
294
+ this.parseXVAL3('rotation', length);
295
+ break;
296
+
297
+ default:
298
+ this.parseUnknownForm(type, length);
299
+ }
300
+
301
+ this.debugger.node = 0;
302
+ this.debugger.nodeID = type;
303
+ this.debugger.log();
304
+ },
305
+ setupForm: function setupForm(type, length) {
306
+ if (!this.currentForm) this.currentForm = this.currentNode;
307
+ this.currentFormEnd = this.reader.offset + length;
308
+ this.parentForm = this.currentForm;
309
+
310
+ if (!this.currentForm[type]) {
311
+ this.currentForm[type] = {};
312
+ this.currentForm = this.currentForm[type];
313
+ } else {
314
+ // should never see this unless there's a bug in the reader
315
+ console.warn('LWOLoader: form already exists on parent: ', type, this.currentForm);
316
+ this.currentForm = this.currentForm[type];
317
+ }
318
+ },
319
+ skipForm: function skipForm(length) {
320
+ this.reader.skip(length - 4);
321
+ },
322
+ parseUnknownForm: function parseUnknownForm(type, length) {
323
+ console.warn('LWOLoader: unknown FORM encountered: ' + type, length);
324
+ printBuffer(this.reader.dv.buffer, this.reader.offset, length - 4);
325
+ this.reader.skip(length - 4);
326
+ },
327
+ parseSurfaceForm: function parseSurfaceForm(length) {
328
+ this.reader.skip(8); // unknown Uint32 x2
329
+
330
+ var name = this.reader.getString();
331
+ var surface = {
332
+ attributes: {},
333
+ // LWO2 style non-node attributes will go here
334
+ connections: {},
335
+ name: name,
336
+ inputName: name,
337
+ nodes: {},
338
+ source: this.reader.getString()
339
+ };
340
+ this.tree.materials[name] = surface;
341
+ this.currentSurface = surface;
342
+ this.parentForm = this.tree.materials;
343
+ this.currentForm = surface;
344
+ this.currentFormEnd = this.reader.offset + length;
345
+ },
346
+ parseSurfaceLwo2: function parseSurfaceLwo2(length) {
347
+ var name = this.reader.getString();
348
+ var surface = {
349
+ attributes: {},
350
+ // LWO2 style non-node attributes will go here
351
+ connections: {},
352
+ name: name,
353
+ nodes: {},
354
+ source: this.reader.getString()
355
+ };
356
+ this.tree.materials[name] = surface;
357
+ this.currentSurface = surface;
358
+ this.parentForm = this.tree.materials;
359
+ this.currentForm = surface;
360
+ this.currentFormEnd = this.reader.offset + length;
361
+ },
362
+ parseSubNode: function parseSubNode(length) {
363
+ // parse the NRNM CHUNK of the subnode FORM to get
364
+ // a meaningful name for the subNode
365
+ // some subnodes can be renamed, but Input and Surface cannot
366
+ this.reader.skip(8); // NRNM + length
367
+
368
+ var name = this.reader.getString();
369
+ var node = {
370
+ name: name
371
+ };
372
+ this.currentForm = node;
373
+ this.currentNode = node;
374
+ this.currentFormEnd = this.reader.offset + length;
375
+ },
376
+ // collect attributes from all nodes at the top level of a surface
377
+ parseConnections: function parseConnections(length) {
378
+ this.currentFormEnd = this.reader.offset + length;
379
+ this.parentForm = this.currentForm;
380
+ this.currentForm = this.currentSurface.connections;
381
+ },
382
+ // surface node attribute data, e.g. specular, roughness etc
383
+ parseEntryForm: function parseEntryForm(length) {
384
+ this.reader.skip(8); // NAME + length
385
+
386
+ var name = this.reader.getString();
387
+ this.currentForm = this.currentNode.attributes;
388
+ this.setupForm(name, length);
389
+ },
390
+ // parse values from material - doesn't match up to other LWO3 data types
391
+ // sub form of entry form
392
+ parseValueForm: function parseValueForm() {
393
+ this.reader.skip(8); // unknown + length
394
+
395
+ var valueType = this.reader.getString();
396
+
397
+ if (valueType === 'double') {
398
+ this.currentForm.value = this.reader.getUint64();
399
+ } else if (valueType === 'int') {
400
+ this.currentForm.value = this.reader.getUint32();
401
+ } else if (valueType === 'vparam') {
402
+ this.reader.skip(24);
403
+ this.currentForm.value = this.reader.getFloat64();
404
+ } else if (valueType === 'vparam3') {
405
+ this.reader.skip(24);
406
+ this.currentForm.value = this.reader.getFloat64Array(3);
407
+ }
408
+ },
409
+ // holds various data about texture node image state
410
+ // Data other thanmipMapLevel unknown
411
+ parseImageStateForm: function parseImageStateForm() {
412
+ this.reader.skip(8); // unknown
413
+
414
+ this.currentForm.mipMapLevel = this.reader.getFloat32();
415
+ },
416
+ // LWO2 style image data node OR LWO3 textures defined at top level in editor (not as SURF node)
417
+ parseImageMap: function parseImageMap(length) {
418
+ this.currentFormEnd = this.reader.offset + length;
419
+ this.parentForm = this.currentForm;
420
+ if (!this.currentForm.maps) this.currentForm.maps = [];
421
+ var map = {};
422
+ this.currentForm.maps.push(map);
423
+ this.currentForm = map;
424
+ this.reader.skip(10); // unknown, could be an issue if it contains a VX
425
+ },
426
+ parseTextureNodeAttribute: function parseTextureNodeAttribute(type) {
427
+ this.reader.skip(28); // FORM + length + VPRM + unknown + Uint32 x2 + float32
428
+
429
+ this.reader.skip(20); // FORM + length + VPVL + float32 + Uint32
430
+
431
+ switch (type) {
432
+ case 'ISCL':
433
+ this.currentNode.scale = this.reader.getFloat32Array(3);
434
+ break;
435
+
436
+ case 'IPOS':
437
+ this.currentNode.position = this.reader.getFloat32Array(3);
438
+ break;
439
+
440
+ case 'IROT':
441
+ this.currentNode.rotation = this.reader.getFloat32Array(3);
442
+ break;
443
+
444
+ case 'IFAL':
445
+ this.currentNode.falloff = this.reader.getFloat32Array(3);
446
+ break;
447
+
448
+ case 'IBMP':
449
+ this.currentNode.amplitude = this.reader.getFloat32();
450
+ break;
451
+
452
+ case 'IUTD':
453
+ this.currentNode.uTiles = this.reader.getFloat32();
454
+ break;
455
+
456
+ case 'IVTD':
457
+ this.currentNode.vTiles = this.reader.getFloat32();
458
+ break;
459
+ }
460
+
461
+ this.reader.skip(2); // unknown
462
+ },
463
+ // ENVL forms are currently ignored
464
+ parseEnvelope: function parseEnvelope(length) {
465
+ this.reader.skip(length - 4); // skipping entirely for now
466
+ },
467
+ ///
468
+ // CHUNK PARSING METHODS
469
+ ///
470
+ // clips can either be defined inside a surface node, or at the top
471
+ // level and they have a different format in each case
472
+ parseClip: function parseClip(length) {
473
+ var tag = this.reader.getIDTag(); // inside surface node
474
+
475
+ if (tag === 'FORM') {
476
+ this.reader.skip(16);
477
+ this.currentNode.fileName = this.reader.getString();
478
+ return;
479
+ } // otherwise top level
480
+
481
+
482
+ this.reader.setOffset(this.reader.offset - 4);
483
+ this.currentFormEnd = this.reader.offset + length;
484
+ this.parentForm = this.currentForm;
485
+ this.reader.skip(8); // unknown
486
+
487
+ var texture = {
488
+ index: this.reader.getUint32()
489
+ };
490
+ this.tree.textures.push(texture);
491
+ this.currentForm = texture;
492
+ },
493
+ parseClipLwo2: function parseClipLwo2(length) {
494
+ var texture = {
495
+ index: this.reader.getUint32(),
496
+ fileName: ''
497
+ }; // seach STIL block
498
+
499
+ while (true) {
500
+ var tag = this.reader.getIDTag();
501
+ var n_length = this.reader.getUint16();
502
+
503
+ if (tag === 'STIL') {
504
+ texture.fileName = this.reader.getString();
505
+ break;
506
+ }
507
+
508
+ if (n_length >= length) {
509
+ break;
510
+ }
511
+ }
512
+
513
+ this.tree.textures.push(texture);
514
+ this.currentForm = texture;
515
+ },
516
+ parseImage: function parseImage() {
517
+ this.reader.skip(8); // unknown
518
+
519
+ this.currentForm.fileName = this.reader.getString();
520
+ },
521
+ parseXVAL: function parseXVAL(type, length) {
522
+ var endOffset = this.reader.offset + length - 4;
523
+ this.reader.skip(8);
524
+ this.currentForm[type] = this.reader.getFloat32();
525
+ this.reader.setOffset(endOffset); // set end offset directly to skip optional envelope
526
+ },
527
+ parseXVAL3: function parseXVAL3(type, length) {
528
+ var endOffset = this.reader.offset + length - 4;
529
+ this.reader.skip(8);
530
+ this.currentForm[type] = {
531
+ x: this.reader.getFloat32(),
532
+ y: this.reader.getFloat32(),
533
+ z: this.reader.getFloat32()
534
+ };
535
+ this.reader.setOffset(endOffset);
536
+ },
537
+ // Tags associated with an object
538
+ // OTAG { type[ID4], tag-string[S0] }
539
+ parseObjectTag: function parseObjectTag() {
540
+ if (!this.tree.objectTags) this.tree.objectTags = {};
541
+ this.tree.objectTags[this.reader.getIDTag()] = {
542
+ tagString: this.reader.getString()
543
+ };
544
+ },
545
+ // Signals the start of a new layer. All the data chunks which follow will be included in this layer until another layer chunk is encountered.
546
+ // LAYR: number[U2], flags[U2], pivot[VEC12], name[S0], parent[U2]
547
+ parseLayer: function parseLayer(length) {
548
+ var layer = {
549
+ number: this.reader.getUint16(),
550
+ flags: this.reader.getUint16(),
551
+ // If the least significant bit of flags is set, the layer is hidden.
552
+ pivot: this.reader.getFloat32Array(3),
553
+ // Note: this seems to be superflous, as the geometry is translated when pivot is present
554
+ name: this.reader.getString()
555
+ };
556
+ this.tree.layers.push(layer);
557
+ this.currentLayer = layer;
558
+ var parsedLength = 16 + stringOffset(this.currentLayer.name); // index ( 2 ) + flags( 2 ) + pivot( 12 ) + stringlength
559
+ // if we have not reached then end of the layer block, there must be a parent defined
560
+
561
+ this.currentLayer.parent = parsedLength < length ? this.reader.getUint16() : -1; // omitted or -1 for no parent
562
+ },
563
+ // VEC12 * ( F4 + F4 + F4 ) array of x,y,z vectors
564
+ // Converting from left to right handed coordinate system:
565
+ // x -> -x and switch material FrontSide -> BackSide
566
+ parsePoints: function parsePoints(length) {
567
+ this.currentPoints = [];
568
+
569
+ for (var i = 0; i < length / 4; i += 3) {
570
+ // z -> -z to match three.js right handed coords
571
+ this.currentPoints.push(this.reader.getFloat32(), this.reader.getFloat32(), -this.reader.getFloat32());
572
+ }
573
+ },
574
+ // parse VMAP or VMAD
575
+ // Associates a set of floating-point vectors with a set of points.
576
+ // VMAP: { type[ID4], dimension[U2], name[S0], ( vert[VX], value[F4] # dimension ) * }
577
+ // VMAD Associates a set of floating-point vectors with the vertices of specific polygons.
578
+ // Similar to VMAP UVs, but associates with polygon vertices rather than points
579
+ // to solve to problem of UV seams: VMAD chunks are paired with VMAPs of the same name,
580
+ // if they exist. The vector values in the VMAD will then replace those in the
581
+ // corresponding VMAP, but only for calculations involving the specified polygons.
582
+ // VMAD { type[ID4], dimension[U2], name[S0], ( vert[VX], poly[VX], value[F4] # dimension ) * }
583
+ parseVertexMapping: function parseVertexMapping(length, discontinuous) {
584
+ var finalOffset = this.reader.offset + length;
585
+ var channelName = this.reader.getString();
586
+
587
+ if (this.reader.offset === finalOffset) {
588
+ // then we are in a texture node and the VMAP chunk is just a reference to a UV channel name
589
+ this.currentForm.UVChannel = channelName;
590
+ return;
591
+ } // otherwise reset to initial length and parse normal VMAP CHUNK
592
+
593
+
594
+ this.reader.setOffset(this.reader.offset - stringOffset(channelName));
595
+ var type = this.reader.getIDTag();
596
+ this.reader.getUint16(); // dimension
597
+
598
+ var name = this.reader.getString();
599
+ var remainingLength = length - 6 - stringOffset(name);
600
+
601
+ switch (type) {
602
+ case 'TXUV':
603
+ this.parseUVMapping(name, finalOffset, discontinuous);
604
+ break;
605
+
606
+ case 'MORF':
607
+ case 'SPOT':
608
+ this.parseMorphTargets(name, finalOffset, type); // can't be discontinuous
609
+
610
+ break;
611
+ // unsupported VMAPs
612
+
613
+ case 'APSL':
614
+ case 'NORM':
615
+ case 'WGHT':
616
+ case 'MNVW':
617
+ case 'PICK':
618
+ case 'RGB ':
619
+ case 'RGBA':
620
+ this.reader.skip(remainingLength);
621
+ break;
622
+
623
+ default:
624
+ console.warn('LWOLoader: unknown vertex map type: ' + type);
625
+ this.reader.skip(remainingLength);
626
+ }
627
+ },
628
+ parseUVMapping: function parseUVMapping(name, finalOffset, discontinuous) {
629
+ var uvIndices = [];
630
+ var polyIndices = [];
631
+ var uvs = [];
632
+
633
+ while (this.reader.offset < finalOffset) {
634
+ uvIndices.push(this.reader.getVariableLengthIndex());
635
+ if (discontinuous) polyIndices.push(this.reader.getVariableLengthIndex());
636
+ uvs.push(this.reader.getFloat32(), this.reader.getFloat32());
637
+ }
638
+
639
+ if (discontinuous) {
640
+ if (!this.currentLayer.discontinuousUVs) this.currentLayer.discontinuousUVs = {};
641
+ this.currentLayer.discontinuousUVs[name] = {
642
+ uvIndices: uvIndices,
643
+ polyIndices: polyIndices,
644
+ uvs: uvs
645
+ };
646
+ } else {
647
+ if (!this.currentLayer.uvs) this.currentLayer.uvs = {};
648
+ this.currentLayer.uvs[name] = {
649
+ uvIndices: uvIndices,
650
+ uvs: uvs
651
+ };
652
+ }
653
+ },
654
+ parseMorphTargets: function parseMorphTargets(name, finalOffset, type) {
655
+ var indices = [];
656
+ var points = [];
657
+ type = type === 'MORF' ? 'relative' : 'absolute';
658
+
659
+ while (this.reader.offset < finalOffset) {
660
+ indices.push(this.reader.getVariableLengthIndex()); // z -> -z to match three.js right handed coords
661
+
662
+ points.push(this.reader.getFloat32(), this.reader.getFloat32(), -this.reader.getFloat32());
663
+ }
664
+
665
+ if (!this.currentLayer.morphTargets) this.currentLayer.morphTargets = {};
666
+ this.currentLayer.morphTargets[name] = {
667
+ indices: indices,
668
+ points: points,
669
+ type: type
670
+ };
671
+ },
672
+ // A list of polygons for the current layer.
673
+ // POLS { type[ID4], ( numvert+flags[U2], vert[VX] # numvert ) * }
674
+ parsePolygonList: function parsePolygonList(length) {
675
+ var finalOffset = this.reader.offset + length;
676
+ var type = this.reader.getIDTag();
677
+ var indices = []; // hold a list of polygon sizes, to be split up later
678
+
679
+ var polygonDimensions = [];
680
+
681
+ while (this.reader.offset < finalOffset) {
682
+ var numverts = this.reader.getUint16(); //var flags = numverts & 64512; // 6 high order bits are flags - ignoring for now
683
+
684
+ numverts = numverts & 1023; // remaining ten low order bits are vertex num
685
+
686
+ polygonDimensions.push(numverts);
687
+
688
+ for (var j = 0; j < numverts; j++) {
689
+ indices.push(this.reader.getVariableLengthIndex());
690
+ }
691
+ }
692
+
693
+ var geometryData = {
694
+ type: type,
695
+ vertexIndices: indices,
696
+ polygonDimensions: polygonDimensions,
697
+ points: this.currentPoints
698
+ }; // Note: assuming that all polys will be lines or points if the first is
699
+
700
+ if (polygonDimensions[0] === 1) geometryData.type = 'points';else if (polygonDimensions[0] === 2) geometryData.type = 'lines';
701
+ this.currentLayer.geometry = geometryData;
702
+ },
703
+ // Lists the tag strings that can be associated with polygons by the PTAG chunk.
704
+ // TAGS { tag-string[S0] * }
705
+ parseTagStrings: function parseTagStrings(length) {
706
+ this.tree.tags = this.reader.getStringArray(length);
707
+ },
708
+ // Associates tags of a given type with polygons in the most recent POLS chunk.
709
+ // PTAG { type[ID4], ( poly[VX], tag[U2] ) * }
710
+ parsePolygonTagMapping: function parsePolygonTagMapping(length) {
711
+ var finalOffset = this.reader.offset + length;
712
+ var type = this.reader.getIDTag();
713
+ if (type === 'SURF') this.parseMaterialIndices(finalOffset);else {
714
+ //PART, SMGP, COLR not supported
715
+ this.reader.skip(length - 4);
716
+ }
717
+ },
718
+ parseMaterialIndices: function parseMaterialIndices(finalOffset) {
719
+ // array holds polygon index followed by material index
720
+ this.currentLayer.geometry.materialIndices = [];
721
+
722
+ while (this.reader.offset < finalOffset) {
723
+ var polygonIndex = this.reader.getVariableLengthIndex();
724
+ var materialIndex = this.reader.getUint16();
725
+ this.currentLayer.geometry.materialIndices.push(polygonIndex, materialIndex);
726
+ }
727
+ },
728
+ parseUnknownCHUNK: function parseUnknownCHUNK(blockID, length) {
729
+ console.warn('LWOLoader: unknown chunk type: ' + blockID + ' length: ' + length); // print the chunk plus some bytes padding either side
730
+ // printBuffer( this.reader.dv.buffer, this.reader.offset - 20, length + 40 );
731
+
732
+ var data = this.reader.getString(length);
733
+ this.currentForm[blockID] = data;
734
+ }
735
+ };
736
+
737
+ function DataViewReader(buffer) {
738
+ this.dv = new DataView(buffer);
739
+ this.offset = 0;
740
+ }
741
+
742
+ DataViewReader.prototype = {
743
+ constructor: DataViewReader,
744
+ size: function size() {
745
+ return this.dv.buffer.byteLength;
746
+ },
747
+ setOffset: function setOffset(offset) {
748
+ if (offset > 0 && offset < this.dv.buffer.byteLength) {
749
+ this.offset = offset;
750
+ } else {
751
+ console.error('LWOLoader: invalid buffer offset');
752
+ }
753
+ },
754
+ endOfFile: function endOfFile() {
755
+ if (this.offset >= this.size()) return true;
756
+ return false;
757
+ },
758
+ skip: function skip(length) {
759
+ this.offset += length;
760
+ },
761
+ getUint8: function getUint8() {
762
+ var value = this.dv.getUint8(this.offset);
763
+ this.offset += 1;
764
+ return value;
765
+ },
766
+ getUint16: function getUint16() {
767
+ var value = this.dv.getUint16(this.offset);
768
+ this.offset += 2;
769
+ return value;
770
+ },
771
+ getInt32: function getInt32() {
772
+ var value = this.dv.getInt32(this.offset, false);
773
+ this.offset += 4;
774
+ return value;
775
+ },
776
+ getUint32: function getUint32() {
777
+ var value = this.dv.getUint32(this.offset, false);
778
+ this.offset += 4;
779
+ return value;
780
+ },
781
+ getUint64: function getUint64() {
782
+ var low, high;
783
+ high = this.getUint32();
784
+ low = this.getUint32();
785
+ return high * 0x100000000 + low;
786
+ },
787
+ getFloat32: function getFloat32() {
788
+ var value = this.dv.getFloat32(this.offset, false);
789
+ this.offset += 4;
790
+ return value;
791
+ },
792
+ getFloat32Array: function getFloat32Array(size) {
793
+ var a = [];
794
+
795
+ for (var i = 0; i < size; i++) {
796
+ a.push(this.getFloat32());
797
+ }
798
+
799
+ return a;
800
+ },
801
+ getFloat64: function getFloat64() {
802
+ var value = this.dv.getFloat64(this.offset, this.littleEndian);
803
+ this.offset += 8;
804
+ return value;
805
+ },
806
+ getFloat64Array: function getFloat64Array(size) {
807
+ var a = [];
808
+
809
+ for (var i = 0; i < size; i++) {
810
+ a.push(this.getFloat64());
811
+ }
812
+
813
+ return a;
814
+ },
815
+ // get variable-length index data type
816
+ // VX ::= index[U2] | (index + 0xFF000000)[U4]
817
+ // If the index value is less than 65,280 (0xFF00),then VX === U2
818
+ // otherwise VX === U4 with bits 24-31 set
819
+ // When reading an index, if the first byte encountered is 255 (0xFF), then
820
+ // the four-byte form is being used and the first byte should be discarded or masked out.
821
+ getVariableLengthIndex: function getVariableLengthIndex() {
822
+ var firstByte = this.getUint8();
823
+
824
+ if (firstByte === 255) {
825
+ return this.getUint8() * 65536 + this.getUint8() * 256 + this.getUint8();
826
+ }
827
+
828
+ return firstByte * 256 + this.getUint8();
829
+ },
830
+ // An ID tag is a sequence of 4 bytes containing 7-bit ASCII values
831
+ getIDTag: function getIDTag() {
832
+ return this.getString(4);
833
+ },
834
+ getString: function getString(size) {
835
+ if (size === 0) return; // note: safari 9 doesn't support Uint8Array.indexOf; create intermediate array instead
836
+
837
+ var a = [];
838
+
839
+ if (size) {
840
+ for (var i = 0; i < size; i++) {
841
+ a[i] = this.getUint8();
842
+ }
843
+ } else {
844
+ var currentChar;
845
+ var len = 0;
846
+
847
+ while (currentChar !== 0) {
848
+ currentChar = this.getUint8();
849
+ if (currentChar !== 0) a.push(currentChar);
850
+ len++;
851
+ }
852
+
853
+ if (!isEven(len + 1)) this.getUint8(); // if string with terminating nullbyte is uneven, extra nullbyte is added
854
+ }
855
+
856
+ return _three.LoaderUtils.decodeText(new Uint8Array(a));
857
+ },
858
+ getStringArray: function getStringArray(size) {
859
+ var a = this.getString(size);
860
+ a = a.split('\0');
861
+ return a.filter(Boolean); // return array with any empty strings removed
862
+ }
863
+ }; // ************** DEBUGGER **************
864
+
865
+ function Debugger() {
866
+ this.active = false;
867
+ this.depth = 0;
868
+ this.formList = [];
869
+ }
870
+
871
+ Debugger.prototype = {
872
+ constructor: Debugger,
873
+ enable: function enable() {
874
+ this.active = true;
875
+ },
876
+ log: function log() {
877
+ if (!this.active) return;
878
+ var nodeType;
879
+
880
+ switch (this.node) {
881
+ case 0:
882
+ nodeType = 'FORM';
883
+ break;
884
+
885
+ case 1:
886
+ nodeType = 'CHK';
887
+ break;
888
+
889
+ case 2:
890
+ nodeType = 'S-CHK';
891
+ break;
892
+ }
893
+
894
+ console.log('| '.repeat(this.depth) + nodeType, this.nodeID, "( ".concat(this.offset, " ) -> ( ").concat(this.dataOffset + this.length, " )"), this.node == 0 ? ' {' : '', this.skipped ? 'SKIPPED' : '', this.node == 0 && this.skipped ? '}' : '');
895
+
896
+ if (this.node == 0 && !this.skipped) {
897
+ this.depth += 1;
898
+ this.formList.push(this.dataOffset + this.length);
899
+ }
900
+
901
+ this.skipped = false;
902
+ },
903
+ closeForms: function closeForms() {
904
+ if (!this.active) return;
905
+
906
+ for (var i = this.formList.length - 1; i >= 0; i--) {
907
+ if (this.offset >= this.formList[i]) {
908
+ this.depth -= 1;
909
+ console.log('| '.repeat(this.depth) + '}');
910
+ this.formList.splice(-1, 1);
911
+ }
912
+ }
913
+ }
914
+ }; // ************** UTILITY FUNCTIONS **************
915
+
916
+ function isEven(num) {
917
+ return num % 2;
918
+ } // calculate the length of the string in the buffer
919
+ // this will be string.length + nullbyte + optional padbyte to make the length even
920
+
921
+
922
+ function stringOffset(string) {
923
+ return string.length + 1 + (isEven(string.length + 1) ? 1 : 0);
924
+ } // for testing purposes, dump buffer to console
925
+ // printBuffer( this.reader.dv.buffer, this.reader.offset, length );
926
+
927
+
928
+ function printBuffer(buffer, from, to) {
929
+ console.log(_three.LoaderUtils.decodeText(new Uint8Array(buffer, from, to)));
930
+ }
931
+ });