@anov/3d 0.0.4-alpha.1 → 0.0.4-alpha13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -144
- package/dist/applicationApi.d.ts +34 -0
- package/dist/{core/cssRenderer.js → applicationApi.js} +53 -21
- package/dist/environment/index.d.ts +27 -0
- package/dist/environment/index.js +84 -0
- package/dist/environment/time/index.d.ts +12 -0
- package/dist/environment/time/index.js +27 -0
- package/dist/environment/weather/type.d.ts +15 -0
- package/dist/environment/weather/type.js +27 -0
- package/dist/hooksManager.d.ts +2 -0
- package/dist/hooksManager.js +15 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.js +38 -5
- package/dist/messageStatus.d.ts +49 -0
- package/dist/messageStatus.js +50 -0
- package/dist/utils/index.d.ts +11 -50
- package/dist/utils/index.js +29 -92
- package/dist/utils/messageFn.d.ts +12 -0
- package/dist/utils/messageFn.js +33 -0
- package/package.json +8 -24
- package/dist/commonEnu.d.ts +0 -5
- package/dist/commonEnu.js +0 -6
- package/dist/core/camera.d.ts +0 -32
- package/dist/core/camera.js +0 -74
- package/dist/core/control/transformControls.d.ts +0 -12
- package/dist/core/control/transformControls.js +0 -72
- package/dist/core/cssRenderer.d.ts +0 -17
- package/dist/core/events.d.ts +0 -16
- package/dist/core/events.js +0 -38
- package/dist/core/global/global.d.ts +0 -27
- package/dist/core/global/global.js +0 -72
- package/dist/core/global/globalControl.d.ts +0 -17
- package/dist/core/global/globalControl.js +0 -62
- package/dist/core/group.d.ts +0 -57
- package/dist/core/group.js +0 -157
- package/dist/core/line.d.ts +0 -13
- package/dist/core/line.js +0 -83
- package/dist/core/mesh.d.ts +0 -59
- package/dist/core/mesh.js +0 -180
- package/dist/core/model.d.ts +0 -30
- package/dist/core/model.js +0 -109
- package/dist/core/scene.d.ts +0 -175
- package/dist/core/scene.js +0 -381
- package/dist/core/use/useScene.d.ts +0 -10
- package/dist/core/use/useScene.js +0 -14
- package/dist/core/use/useframe.d.ts +0 -6
- package/dist/core/use/useframe.js +0 -11
- package/dist/export.d.ts +0 -40
- package/dist/export.js +0 -36
- package/dist/threeCell.d.ts +0 -8
- package/dist/threeCell.js +0 -16
- package/dist/type.d.ts +0 -3
- package/dist/type.js +0 -1
- package/dist/utils/createElement.d.ts +0 -103
- package/dist/utils/createElement.js +0 -145
- package/dist/utils/createLabel.d.ts +0 -2
- package/dist/utils/createLabel.js +0 -4
- package/dist/utils/line.d.ts +0 -0
- package/dist/utils/line.js +0 -0
- package/dist/utils/move.d.ts +0 -48
- package/dist/utils/move.js +0 -149
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/animation/AnimationClipCreator.js +0 -116
- package/examples/jsm/animation/CCDIKSolver.js +0 -482
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1207
- package/examples/jsm/animation/MMDPhysics.js +0 -1406
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/examples/jsm/capabilities/WebGL.js +0 -91
- package/examples/jsm/capabilities/WebGPU.js +0 -53
- package/examples/jsm/controls/ArcballControls.js +0 -3224
- package/examples/jsm/controls/DragControls.js +0 -220
- package/examples/jsm/controls/FirstPersonControls.js +0 -325
- package/examples/jsm/controls/FlyControls.js +0 -300
- package/examples/jsm/controls/MapControls.js +0 -28
- package/examples/jsm/controls/OrbitControls.js +0 -1388
- package/examples/jsm/controls/PointerLockControls.js +0 -162
- package/examples/jsm/controls/TrackballControls.js +0 -828
- package/examples/jsm/controls/TransformControls.js +0 -1557
- package/examples/jsm/csm/CSM.js +0 -384
- package/examples/jsm/csm/CSMFrustum.js +0 -152
- package/examples/jsm/csm/CSMHelper.js +0 -193
- package/examples/jsm/csm/CSMShader.js +0 -252
- package/examples/jsm/curves/CurveExtras.js +0 -422
- package/examples/jsm/curves/NURBSCurve.js +0 -80
- package/examples/jsm/curves/NURBSSurface.js +0 -52
- package/examples/jsm/curves/NURBSUtils.js +0 -487
- package/examples/jsm/effects/AnaglyphEffect.js +0 -154
- package/examples/jsm/effects/AsciiEffect.js +0 -263
- package/examples/jsm/effects/OutlineEffect.js +0 -539
- package/examples/jsm/effects/ParallaxBarrierEffect.js +0 -119
- package/examples/jsm/effects/PeppersGhostEffect.js +0 -153
- package/examples/jsm/effects/StereoEffect.js +0 -55
- package/examples/jsm/environments/DebugEnvironment.js +0 -52
- package/examples/jsm/environments/RoomEnvironment.js +0 -148
- package/examples/jsm/exporters/DRACOExporter.js +0 -267
- package/examples/jsm/exporters/EXRExporter.js +0 -501
- package/examples/jsm/exporters/GLTFExporter.js +0 -3161
- package/examples/jsm/exporters/KTX2Exporter.js +0 -292
- package/examples/jsm/exporters/MMDExporter.js +0 -217
- package/examples/jsm/exporters/OBJExporter.js +0 -284
- package/examples/jsm/exporters/PLYExporter.js +0 -528
- package/examples/jsm/exporters/STLExporter.js +0 -199
- package/examples/jsm/exporters/USDZExporter.js +0 -711
- package/examples/jsm/geometries/BoxLineGeometry.js +0 -69
- package/examples/jsm/geometries/ConvexGeometry.js +0 -53
- package/examples/jsm/geometries/DecalGeometry.js +0 -356
- package/examples/jsm/geometries/ParametricGeometries.js +0 -254
- package/examples/jsm/geometries/ParametricGeometry.js +0 -139
- package/examples/jsm/geometries/RoundedBoxGeometry.js +0 -155
- package/examples/jsm/geometries/TeapotGeometry.js +0 -704
- package/examples/jsm/geometries/TextGeometry.js +0 -57
- package/examples/jsm/helpers/LightProbeHelper.js +0 -130
- package/examples/jsm/helpers/OctreeHelper.js +0 -73
- package/examples/jsm/helpers/PositionalAudioHelper.js +0 -109
- package/examples/jsm/helpers/RectAreaLightHelper.js +0 -85
- package/examples/jsm/helpers/VertexNormalsHelper.js +0 -96
- package/examples/jsm/helpers/VertexTangentsHelper.js +0 -88
- package/examples/jsm/helpers/ViewHelper.js +0 -333
- package/examples/jsm/interactive/HTMLMesh.js +0 -565
- package/examples/jsm/interactive/InteractiveGroup.js +0 -116
- package/examples/jsm/interactive/SelectionBox.js +0 -227
- package/examples/jsm/interactive/SelectionHelper.js +0 -104
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/basis/README.md +0 -46
- package/examples/jsm/libs/basis/basis_transcoder.js +0 -21
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/chevrotain.module.min.js +0 -141
- package/examples/jsm/libs/draco/README.md +0 -32
- package/examples/jsm/libs/draco/draco_decoder.js +0 -34
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +0 -117
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +0 -116
- package/examples/jsm/libs/ecsy.module.js +0 -1792
- package/examples/jsm/libs/fflate.module.js +0 -2474
- package/examples/jsm/libs/ktx-parse.module.js +0 -1
- package/examples/jsm/libs/lil-gui.module.min.js +0 -8
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14844
- package/examples/jsm/libs/meshopt_decoder.module.js +0 -178
- package/examples/jsm/libs/mikktspace.module.js +0 -128
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/libs/motion-controllers.module.js +0 -397
- package/examples/jsm/libs/opentype.module.js +0 -14568
- package/examples/jsm/libs/potpack.module.js +0 -125
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +0 -167
- package/examples/jsm/libs/tween.module.js +0 -803
- package/examples/jsm/libs/utif.module.js +0 -1579
- package/examples/jsm/libs/zstddec.module.js +0 -1
- package/examples/jsm/lights/IESSpotLight.js +0 -25
- package/examples/jsm/lights/LightProbeGenerator.js +0 -252
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +0 -79
- package/examples/jsm/lines/Line2.js +0 -19
- package/examples/jsm/lines/LineGeometry.js +0 -79
- package/examples/jsm/lines/LineMaterial.js +0 -702
- package/examples/jsm/lines/LineSegments2.js +0 -361
- package/examples/jsm/lines/LineSegmentsGeometry.js +0 -241
- package/examples/jsm/lines/Wireframe.js +0 -56
- package/examples/jsm/lines/WireframeGeometry2.js +0 -24
- package/examples/jsm/loaders/3DMLoader.js +0 -1497
- package/examples/jsm/loaders/3MFLoader.js +0 -1478
- package/examples/jsm/loaders/AMFLoader.js +0 -521
- package/examples/jsm/loaders/BVHLoader.js +0 -437
- package/examples/jsm/loaders/ColladaLoader.js +0 -4122
- package/examples/jsm/loaders/DDSLoader.js +0 -274
- package/examples/jsm/loaders/DRACOLoader.js +0 -612
- package/examples/jsm/loaders/EXRLoader.js +0 -2309
- package/examples/jsm/loaders/FBXLoader.js +0 -4142
- package/examples/jsm/loaders/FontLoader.js +0 -183
- package/examples/jsm/loaders/GCodeLoader.js +0 -261
- package/examples/jsm/loaders/GLTFLoader.js +0 -4576
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +0 -115
- package/examples/jsm/loaders/IESLoader.js +0 -337
- package/examples/jsm/loaders/KMZLoader.js +0 -130
- package/examples/jsm/loaders/KTX2Loader.js +0 -868
- package/examples/jsm/loaders/KTXLoader.js +0 -176
- package/examples/jsm/loaders/LDrawLoader.js +0 -2464
- package/examples/jsm/loaders/LUT3dlLoader.js +0 -151
- package/examples/jsm/loaders/LUTCubeLoader.js +0 -153
- package/examples/jsm/loaders/LWOLoader.js +0 -1052
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/examples/jsm/loaders/LottieLoader.js +0 -77
- package/examples/jsm/loaders/MD2Loader.js +0 -399
- package/examples/jsm/loaders/MDDLoader.js +0 -102
- package/examples/jsm/loaders/MMDLoader.js +0 -2273
- package/examples/jsm/loaders/MTLLoader.js +0 -567
- package/examples/jsm/loaders/MaterialXLoader.js +0 -734
- package/examples/jsm/loaders/NRRDLoader.js +0 -699
- package/examples/jsm/loaders/OBJLoader.js +0 -905
- package/examples/jsm/loaders/PCDLoader.js +0 -467
- package/examples/jsm/loaders/PDBLoader.js +0 -232
- package/examples/jsm/loaders/PLYLoader.js +0 -771
- package/examples/jsm/loaders/PVRLoader.js +0 -251
- package/examples/jsm/loaders/RGBELoader.js +0 -468
- package/examples/jsm/loaders/RGBMLoader.js +0 -1065
- package/examples/jsm/loaders/STLLoader.js +0 -403
- package/examples/jsm/loaders/SVGLoader.js +0 -3172
- package/examples/jsm/loaders/TDSLoader.js +0 -1124
- package/examples/jsm/loaders/TGALoader.js +0 -517
- package/examples/jsm/loaders/TIFFLoader.js +0 -36
- package/examples/jsm/loaders/TTFLoader.js +0 -214
- package/examples/jsm/loaders/TiltLoader.js +0 -520
- package/examples/jsm/loaders/USDZLoader.js +0 -633
- package/examples/jsm/loaders/VOXLoader.js +0 -311
- package/examples/jsm/loaders/VRMLLoader.js +0 -3533
- package/examples/jsm/loaders/VTKLoader.js +0 -1163
- package/examples/jsm/loaders/XYZLoader.js +0 -106
- package/examples/jsm/loaders/lwo/IFFParser.js +0 -1218
- package/examples/jsm/loaders/lwo/LWO2Parser.js +0 -414
- package/examples/jsm/loaders/lwo/LWO3Parser.js +0 -373
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -420
- package/examples/jsm/math/Capsule.js +0 -137
- package/examples/jsm/math/ColorConverter.js +0 -36
- package/examples/jsm/math/ConvexHull.js +0 -1271
- package/examples/jsm/math/ImprovedNoise.js +0 -71
- package/examples/jsm/math/Lut.js +0 -204
- package/examples/jsm/math/MeshSurfaceSampler.js +0 -250
- package/examples/jsm/math/OBB.js +0 -423
- package/examples/jsm/math/Octree.js +0 -462
- package/examples/jsm/math/SimplexNoise.js +0 -444
- package/examples/jsm/misc/ConvexObjectBreaker.js +0 -519
- package/examples/jsm/misc/GPUComputationRenderer.js +0 -446
- package/examples/jsm/misc/Gyroscope.js +0 -66
- package/examples/jsm/misc/MD2Character.js +0 -276
- package/examples/jsm/misc/MD2CharacterComplex.js +0 -576
- package/examples/jsm/misc/MorphAnimMesh.js +0 -75
- package/examples/jsm/misc/MorphBlendMesh.js +0 -322
- package/examples/jsm/misc/ProgressiveLightMap.js +0 -323
- package/examples/jsm/misc/RollerCoaster.js +0 -566
- package/examples/jsm/misc/TubePainter.js +0 -205
- package/examples/jsm/misc/Volume.js +0 -473
- package/examples/jsm/misc/VolumeSlice.js +0 -229
- package/examples/jsm/modifiers/CurveModifier.js +0 -326
- package/examples/jsm/modifiers/EdgeSplitModifier.js +0 -279
- package/examples/jsm/modifiers/SimplifyModifier.js +0 -525
- package/examples/jsm/modifiers/TessellateModifier.js +0 -307
- package/examples/jsm/nodes/Nodes.js +0 -171
- package/examples/jsm/nodes/accessors/BitangentNode.js +0 -89
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +0 -99
- package/examples/jsm/nodes/accessors/BufferNode.js +0 -30
- package/examples/jsm/nodes/accessors/CameraNode.js +0 -98
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +0 -103
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -77
- package/examples/jsm/nodes/accessors/InstanceNode.js +0 -71
- package/examples/jsm/nodes/accessors/MaterialNode.js +0 -267
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +0 -39
- package/examples/jsm/nodes/accessors/ModelNode.js +0 -34
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +0 -29
- package/examples/jsm/nodes/accessors/MorphNode.js +0 -70
- package/examples/jsm/nodes/accessors/NormalNode.js +0 -96
- package/examples/jsm/nodes/accessors/Object3DNode.js +0 -150
- package/examples/jsm/nodes/accessors/PointUVNode.js +0 -26
- package/examples/jsm/nodes/accessors/PositionNode.js +0 -104
- package/examples/jsm/nodes/accessors/ReferenceNode.js +0 -72
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +0 -35
- package/examples/jsm/nodes/accessors/SceneNode.js +0 -52
- package/examples/jsm/nodes/accessors/SkinningNode.js +0 -93
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +0 -27
- package/examples/jsm/nodes/accessors/TangentNode.js +0 -103
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +0 -94
- package/examples/jsm/nodes/accessors/TextureNode.js +0 -271
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +0 -35
- package/examples/jsm/nodes/accessors/UVNode.js +0 -47
- package/examples/jsm/nodes/accessors/UserDataNode.js +0 -29
- package/examples/jsm/nodes/code/CodeNode.js +0 -78
- package/examples/jsm/nodes/code/ExpressionNode.js +0 -37
- package/examples/jsm/nodes/code/FunctionCallNode.js +0 -96
- package/examples/jsm/nodes/code/FunctionNode.js +0 -127
- package/examples/jsm/nodes/code/ScriptableNode.js +0 -488
- package/examples/jsm/nodes/code/ScriptableValueNode.js +0 -167
- package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
- package/examples/jsm/nodes/core/AttributeNode.js +0 -102
- package/examples/jsm/nodes/core/BypassNode.js +0 -45
- package/examples/jsm/nodes/core/CacheNode.js +0 -46
- package/examples/jsm/nodes/core/ConstNode.js +0 -32
- package/examples/jsm/nodes/core/ContextNode.js +0 -61
- package/examples/jsm/nodes/core/IndexNode.js +0 -66
- package/examples/jsm/nodes/core/InputNode.js +0 -83
- package/examples/jsm/nodes/core/LightingModel.js +0 -15
- package/examples/jsm/nodes/core/Node.js +0 -454
- package/examples/jsm/nodes/core/NodeAttribute.js +0 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +0 -1016
- package/examples/jsm/nodes/core/NodeCache.js +0 -26
- package/examples/jsm/nodes/core/NodeCode.js +0 -15
- package/examples/jsm/nodes/core/NodeFrame.js +0 -110
- package/examples/jsm/nodes/core/NodeFunction.js +0 -22
- package/examples/jsm/nodes/core/NodeFunctionInput.js +0 -17
- package/examples/jsm/nodes/core/NodeKeywords.js +0 -80
- package/examples/jsm/nodes/core/NodeParser.js +0 -11
- package/examples/jsm/nodes/core/NodeUniform.js +0 -28
- package/examples/jsm/nodes/core/NodeUtils.js +0 -212
- package/examples/jsm/nodes/core/NodeVar.js +0 -14
- package/examples/jsm/nodes/core/NodeVarying.js +0 -17
- package/examples/jsm/nodes/core/PropertyNode.js +0 -61
- package/examples/jsm/nodes/core/StackNode.js +0 -99
- package/examples/jsm/nodes/core/TempNode.js +0 -58
- package/examples/jsm/nodes/core/UniformNode.js +0 -61
- package/examples/jsm/nodes/core/VarNode.js +0 -87
- package/examples/jsm/nodes/core/VaryingNode.js +0 -69
- package/examples/jsm/nodes/core/constants.js +0 -27
- package/examples/jsm/nodes/display/BlendModeNode.js +0 -99
- package/examples/jsm/nodes/display/BumpMapNode.js +0 -77
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +0 -100
- package/examples/jsm/nodes/display/ColorSpaceNode.js +0 -108
- package/examples/jsm/nodes/display/FrontFacingNode.js +0 -27
- package/examples/jsm/nodes/display/NormalMapNode.js +0 -106
- package/examples/jsm/nodes/display/PosterizeNode.js +0 -32
- package/examples/jsm/nodes/display/ToneMappingNode.js +0 -141
- package/examples/jsm/nodes/display/ViewportDepthNode.js +0 -69
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +0 -34
- package/examples/jsm/nodes/display/ViewportNode.js +0 -115
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +0 -31
- package/examples/jsm/nodes/display/ViewportTextureNode.js +0 -75
- package/examples/jsm/nodes/fog/FogExp2Node.js +0 -35
- package/examples/jsm/nodes/fog/FogNode.js +0 -37
- package/examples/jsm/nodes/fog/FogRangeNode.js +0 -34
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +0 -40
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +0 -9
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +0 -43
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +0 -29
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +0 -18
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +0 -13
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +0 -16
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +0 -13
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +0 -20
- package/examples/jsm/nodes/functions/PhongLightingModel.js +0 -67
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +0 -343
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +0 -13
- package/examples/jsm/nodes/functions/material/getRoughness.js +0 -18
- package/examples/jsm/nodes/geometry/RangeNode.js +0 -104
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +0 -85
- package/examples/jsm/nodes/lighting/AONode.js +0 -27
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +0 -27
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +0 -184
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +0 -40
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +0 -191
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +0 -55
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +0 -39
- package/examples/jsm/nodes/lighting/LightNode.js +0 -57
- package/examples/jsm/nodes/lighting/LightUtils.js +0 -17
- package/examples/jsm/nodes/lighting/LightingContextNode.js +0 -102
- package/examples/jsm/nodes/lighting/LightingNode.js +0 -21
- package/examples/jsm/nodes/lighting/LightsNode.js +0 -128
- package/examples/jsm/nodes/lighting/PointLightNode.js +0 -68
- package/examples/jsm/nodes/lighting/SpotLightNode.js +0 -89
- package/examples/jsm/nodes/loaders/NodeLoader.js +0 -108
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +0 -59
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +0 -70
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +0 -28
- package/examples/jsm/nodes/materials/Materials.js +0 -12
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +0 -27
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +0 -34
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +0 -65
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +0 -128
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +0 -80
- package/examples/jsm/nodes/materials/NodeMaterial.js +0 -536
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -49
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -103
- package/examples/jsm/nodes/materialx/DISCLAIMER.md +0 -199
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +0 -68
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +0 -56
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +0 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +0 -19
- package/examples/jsm/nodes/math/CondNode.js +0 -86
- package/examples/jsm/nodes/math/MathNode.js +0 -359
- package/examples/jsm/nodes/math/OperatorNode.js +0 -269
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +0 -152
- package/examples/jsm/nodes/parsers/GLSLNodeParser.js +0 -14
- package/examples/jsm/nodes/procedural/CheckerNode.js +0 -42
- package/examples/jsm/nodes/shadernode/ShaderNode.js +0 -420
- package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -33
- package/examples/jsm/nodes/utils/ConvertNode.js +0 -65
- package/examples/jsm/nodes/utils/DiscardNode.js +0 -26
- package/examples/jsm/nodes/utils/EquirectUVNode.js +0 -33
- package/examples/jsm/nodes/utils/JoinNode.js +0 -51
- package/examples/jsm/nodes/utils/LoopNode.js +0 -186
- package/examples/jsm/nodes/utils/MatcapUVNode.js +0 -30
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +0 -46
- package/examples/jsm/nodes/utils/OscNode.js +0 -81
- package/examples/jsm/nodes/utils/PackingNode.js +0 -55
- package/examples/jsm/nodes/utils/RemapNode.js +0 -42
- package/examples/jsm/nodes/utils/RotateUVNode.js +0 -43
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
- package/examples/jsm/nodes/utils/SplitNode.js +0 -104
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +0 -41
- package/examples/jsm/nodes/utils/TimerNode.js +0 -94
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +0 -62
- package/examples/jsm/objects/GroundProjectedSkybox.js +0 -172
- package/examples/jsm/objects/Lensflare.js +0 -377
- package/examples/jsm/objects/MarchingCubes.js +0 -1176
- package/examples/jsm/objects/Reflector.js +0 -264
- package/examples/jsm/objects/ReflectorForSSRPass.js +0 -349
- package/examples/jsm/objects/Refractor.js +0 -324
- package/examples/jsm/objects/ShadowMesh.js +0 -80
- package/examples/jsm/objects/Sky.js +0 -219
- package/examples/jsm/objects/Water.js +0 -330
- package/examples/jsm/objects/Water2.js +0 -358
- package/examples/jsm/offscreen/jank.js +0 -45
- package/examples/jsm/offscreen/offscreen.js +0 -8
- package/examples/jsm/offscreen/scene.js +0 -86
- package/examples/jsm/physics/AmmoPhysics.js +0 -285
- package/examples/jsm/physics/RapierPhysics.js +0 -199
- package/examples/jsm/postprocessing/AfterimagePass.js +0 -104
- package/examples/jsm/postprocessing/BloomPass.js +0 -172
- package/examples/jsm/postprocessing/BokehPass.js +0 -140
- package/examples/jsm/postprocessing/ClearPass.js +0 -46
- package/examples/jsm/postprocessing/CubeTexturePass.js +0 -85
- package/examples/jsm/postprocessing/DotScreenPass.js +0 -65
- package/examples/jsm/postprocessing/EffectComposer.js +0 -231
- package/examples/jsm/postprocessing/FilmPass.js +0 -66
- package/examples/jsm/postprocessing/GlitchPass.js +0 -128
- package/examples/jsm/postprocessing/HalftonePass.js +0 -79
- package/examples/jsm/postprocessing/LUTPass.js +0 -173
- package/examples/jsm/postprocessing/MaskPass.js +0 -104
- package/examples/jsm/postprocessing/OutlinePass.js +0 -654
- package/examples/jsm/postprocessing/OutputPass.js +0 -91
- package/examples/jsm/postprocessing/Pass.js +0 -84
- package/examples/jsm/postprocessing/RenderPass.js +0 -81
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +0 -235
- package/examples/jsm/postprocessing/SAOPass.js +0 -411
- package/examples/jsm/postprocessing/SMAAPass.js +0 -201
- package/examples/jsm/postprocessing/SSAARenderPass.js +0 -228
- package/examples/jsm/postprocessing/SSAOPass.js +0 -440
- package/examples/jsm/postprocessing/SSRPass.js +0 -641
- package/examples/jsm/postprocessing/SavePass.js +0 -79
- package/examples/jsm/postprocessing/ShaderPass.js +0 -77
- package/examples/jsm/postprocessing/TAARenderPass.js +0 -189
- package/examples/jsm/postprocessing/TexturePass.js +0 -67
- package/examples/jsm/postprocessing/UnrealBloomPass.js +0 -415
- package/examples/jsm/renderers/CSS2DRenderer.js +0 -215
- package/examples/jsm/renderers/CSS3DRenderer.js +0 -335
- package/examples/jsm/renderers/Projector.js +0 -918
- package/examples/jsm/renderers/SVGRenderer.js +0 -553
- package/examples/jsm/renderers/common/Animation.js +0 -58
- package/examples/jsm/renderers/common/Attributes.js +0 -75
- package/examples/jsm/renderers/common/Backend.js +0 -162
- package/examples/jsm/renderers/common/Background.js +0 -136
- package/examples/jsm/renderers/common/Binding.js +0 -19
- package/examples/jsm/renderers/common/Bindings.js +0 -165
- package/examples/jsm/renderers/common/Buffer.js +0 -38
- package/examples/jsm/renderers/common/BufferUtils.js +0 -33
- package/examples/jsm/renderers/common/ChainMap.js +0 -89
- package/examples/jsm/renderers/common/ComputePipeline.js +0 -17
- package/examples/jsm/renderers/common/Constants.js +0 -14
- package/examples/jsm/renderers/common/CubeRenderTarget.js +0 -65
- package/examples/jsm/renderers/common/DataMap.js +0 -54
- package/examples/jsm/renderers/common/Geometries.js +0 -215
- package/examples/jsm/renderers/common/Info.js +0 -73
- package/examples/jsm/renderers/common/Pipeline.js +0 -13
- package/examples/jsm/renderers/common/Pipelines.js +0 -370
- package/examples/jsm/renderers/common/ProgrammableStage.js +0 -18
- package/examples/jsm/renderers/common/RenderContext.js +0 -38
- package/examples/jsm/renderers/common/RenderContexts.js +0 -49
- package/examples/jsm/renderers/common/RenderList.js +0 -178
- package/examples/jsm/renderers/common/RenderLists.js +0 -38
- package/examples/jsm/renderers/common/RenderObject.js +0 -129
- package/examples/jsm/renderers/common/RenderObjects.js +0 -95
- package/examples/jsm/renderers/common/RenderPipeline.js +0 -16
- package/examples/jsm/renderers/common/Renderer.js +0 -895
- package/examples/jsm/renderers/common/SampledTexture.js +0 -80
- package/examples/jsm/renderers/common/Sampler.js +0 -18
- package/examples/jsm/renderers/common/StorageBuffer.js +0 -17
- package/examples/jsm/renderers/common/Textures.js +0 -218
- package/examples/jsm/renderers/common/Uniform.js +0 -140
- package/examples/jsm/renderers/common/UniformBuffer.js +0 -15
- package/examples/jsm/renderers/common/UniformsGroup.js +0 -299
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +0 -39
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +0 -21
- package/examples/jsm/renderers/common/nodes/NodeUniform.js +0 -135
- package/examples/jsm/renderers/common/nodes/Nodes.js +0 -330
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +0 -340
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +0 -764
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +0 -49
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +0 -844
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +0 -32
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +0 -902
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +0 -104
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.js +0 -14
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +0 -274
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +0 -223
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +0 -324
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +0 -533
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +0 -964
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +0 -92
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +0 -87
- package/examples/jsm/shaders/AfterimageShader.js +0 -56
- package/examples/jsm/shaders/BasicShader.js +0 -27
- package/examples/jsm/shaders/BleachBypassShader.js +0 -62
- package/examples/jsm/shaders/BlendShader.js +0 -47
- package/examples/jsm/shaders/BokehShader.js +0 -143
- package/examples/jsm/shaders/BokehShader2.js +0 -393
- package/examples/jsm/shaders/BrightnessContrastShader.js +0 -54
- package/examples/jsm/shaders/ColorCorrectionShader.js +0 -50
- package/examples/jsm/shaders/ColorifyShader.js +0 -51
- package/examples/jsm/shaders/ConvolutionShader.js +0 -103
- package/examples/jsm/shaders/CopyShader.js +0 -45
- package/examples/jsm/shaders/DOFMipMapShader.js +0 -54
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +0 -166
- package/examples/jsm/shaders/DigitalGlitch.js +0 -101
- package/examples/jsm/shaders/DotScreenShader.js +0 -70
- package/examples/jsm/shaders/ExposureShader.js +0 -44
- package/examples/jsm/shaders/FXAAShader.js +0 -286
- package/examples/jsm/shaders/FilmShader.js +0 -102
- package/examples/jsm/shaders/FocusShader.js +0 -87
- package/examples/jsm/shaders/FreiChenShader.js +0 -94
- package/examples/jsm/shaders/GammaCorrectionShader.js +0 -43
- package/examples/jsm/shaders/GodRaysShader.js +0 -313
- package/examples/jsm/shaders/HalftoneShader.js +0 -310
- package/examples/jsm/shaders/HorizontalBlurShader.js +0 -59
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +0 -61
- package/examples/jsm/shaders/HueSaturationShader.js +0 -65
- package/examples/jsm/shaders/KaleidoShader.js +0 -56
- package/examples/jsm/shaders/LuminosityHighPassShader.js +0 -64
- package/examples/jsm/shaders/LuminosityShader.js +0 -46
- package/examples/jsm/shaders/MMDToonShader.js +0 -132
- package/examples/jsm/shaders/MirrorShader.js +0 -54
- package/examples/jsm/shaders/NormalMapShader.js +0 -53
- package/examples/jsm/shaders/OutputShader.js +0 -78
- package/examples/jsm/shaders/RGBShiftShader.js +0 -54
- package/examples/jsm/shaders/SAOShader.js +0 -188
- package/examples/jsm/shaders/SMAAShader.js +0 -460
- package/examples/jsm/shaders/SSAOShader.js +0 -288
- package/examples/jsm/shaders/SSRShader.js +0 -364
- package/examples/jsm/shaders/SepiaShader.js +0 -52
- package/examples/jsm/shaders/SobelOperatorShader.js +0 -90
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +0 -88
- package/examples/jsm/shaders/TechnicolorShader.js +0 -43
- package/examples/jsm/shaders/ToonShader.js +0 -326
- package/examples/jsm/shaders/TriangleBlurShader.js +0 -72
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +0 -45
- package/examples/jsm/shaders/VelocityShader.js +0 -128
- package/examples/jsm/shaders/VerticalBlurShader.js +0 -59
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +0 -61
- package/examples/jsm/shaders/VignetteShader.js +0 -51
- package/examples/jsm/shaders/VolumeShader.js +0 -289
- package/examples/jsm/shaders/WaterRefractionShader.js +0 -93
- package/examples/jsm/textures/FlakesTexture.js +0 -40
- package/examples/jsm/utils/BufferGeometryUtils.js +0 -1373
- package/examples/jsm/utils/CameraUtils.js +0 -73
- package/examples/jsm/utils/GPUStatsPanel.js +0 -128
- package/examples/jsm/utils/GeometryCompressionUtils.js +0 -639
- package/examples/jsm/utils/GeometryUtils.js +0 -221
- package/examples/jsm/utils/LDrawUtils.js +0 -202
- package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
- package/examples/jsm/utils/SceneUtils.js +0 -254
- package/examples/jsm/utils/ShadowMapViewer.js +0 -210
- package/examples/jsm/utils/SkeletonUtils.js +0 -413
- package/examples/jsm/utils/TextureUtils.js +0 -86
- package/examples/jsm/utils/UVsDebug.js +0 -165
- package/examples/jsm/utils/WorkerPool.js +0 -102
- package/examples/jsm/webxr/ARButton.js +0 -208
- package/examples/jsm/webxr/OculusHandModel.js +0 -109
- package/examples/jsm/webxr/OculusHandPointerModel.js +0 -413
- package/examples/jsm/webxr/Text2D.js +0 -38
- package/examples/jsm/webxr/VRButton.js +0 -200
- package/examples/jsm/webxr/XRButton.js +0 -198
- package/examples/jsm/webxr/XRControllerModelFactory.js +0 -299
- package/examples/jsm/webxr/XREstimatedLight.js +0 -223
- package/examples/jsm/webxr/XRHandMeshModel.js +0 -112
- package/examples/jsm/webxr/XRHandModelFactory.js +0 -105
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +0 -103
- package/examples/jsm/webxr/XRPlanes.js +0 -100
- package/lib/3d.min.js +0 -1
|
@@ -1,1497 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BufferGeometryLoader,
|
|
3
|
-
FileLoader,
|
|
4
|
-
Loader,
|
|
5
|
-
Object3D,
|
|
6
|
-
MeshStandardMaterial,
|
|
7
|
-
Mesh,
|
|
8
|
-
Color,
|
|
9
|
-
Points,
|
|
10
|
-
PointsMaterial,
|
|
11
|
-
Line,
|
|
12
|
-
LineBasicMaterial,
|
|
13
|
-
Matrix4,
|
|
14
|
-
DirectionalLight,
|
|
15
|
-
PointLight,
|
|
16
|
-
SpotLight,
|
|
17
|
-
RectAreaLight,
|
|
18
|
-
Sprite,
|
|
19
|
-
SpriteMaterial,
|
|
20
|
-
CanvasTexture,
|
|
21
|
-
LinearFilter,
|
|
22
|
-
ClampToEdgeWrapping,
|
|
23
|
-
RepeatWrapping,
|
|
24
|
-
TextureLoader,
|
|
25
|
-
DoubleSide
|
|
26
|
-
} from 'three';
|
|
27
|
-
|
|
28
|
-
const _taskCache = new WeakMap();
|
|
29
|
-
|
|
30
|
-
class Rhino3dmLoader extends Loader {
|
|
31
|
-
|
|
32
|
-
constructor( manager ) {
|
|
33
|
-
|
|
34
|
-
super( manager );
|
|
35
|
-
|
|
36
|
-
this.libraryPath = '';
|
|
37
|
-
this.libraryPending = null;
|
|
38
|
-
this.libraryBinary = null;
|
|
39
|
-
this.libraryConfig = {};
|
|
40
|
-
|
|
41
|
-
this.url = '';
|
|
42
|
-
|
|
43
|
-
this.workerLimit = 4;
|
|
44
|
-
this.workerPool = [];
|
|
45
|
-
this.workerNextTaskID = 1;
|
|
46
|
-
this.workerSourceURL = '';
|
|
47
|
-
this.workerConfig = {};
|
|
48
|
-
|
|
49
|
-
this.materials = [];
|
|
50
|
-
this.warnings = [];
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setLibraryPath( path ) {
|
|
55
|
-
|
|
56
|
-
this.libraryPath = path;
|
|
57
|
-
|
|
58
|
-
return this;
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
setWorkerLimit( workerLimit ) {
|
|
63
|
-
|
|
64
|
-
this.workerLimit = workerLimit;
|
|
65
|
-
|
|
66
|
-
return this;
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
load( url, onLoad, onProgress, onError ) {
|
|
71
|
-
|
|
72
|
-
const loader = new FileLoader( this.manager );
|
|
73
|
-
|
|
74
|
-
loader.setPath( this.path );
|
|
75
|
-
loader.setResponseType( 'arraybuffer' );
|
|
76
|
-
loader.setRequestHeader( this.requestHeader );
|
|
77
|
-
|
|
78
|
-
this.url = url;
|
|
79
|
-
|
|
80
|
-
loader.load( url, ( buffer ) => {
|
|
81
|
-
|
|
82
|
-
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
83
|
-
// again from this thread.
|
|
84
|
-
if ( _taskCache.has( buffer ) ) {
|
|
85
|
-
|
|
86
|
-
const cachedTask = _taskCache.get( buffer );
|
|
87
|
-
|
|
88
|
-
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
this.decodeObjects( buffer, url )
|
|
93
|
-
.then( result => {
|
|
94
|
-
|
|
95
|
-
result.userData.warnings = this.warnings;
|
|
96
|
-
onLoad( result );
|
|
97
|
-
|
|
98
|
-
} )
|
|
99
|
-
.catch( e => onError( e ) );
|
|
100
|
-
|
|
101
|
-
}, onProgress, onError );
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
debug() {
|
|
106
|
-
|
|
107
|
-
console.log( 'Task load: ', this.workerPool.map( ( worker ) => worker._taskLoad ) );
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
decodeObjects( buffer, url ) {
|
|
112
|
-
|
|
113
|
-
let worker;
|
|
114
|
-
let taskID;
|
|
115
|
-
|
|
116
|
-
const taskCost = buffer.byteLength;
|
|
117
|
-
|
|
118
|
-
const objectPending = this._getWorker( taskCost )
|
|
119
|
-
.then( ( _worker ) => {
|
|
120
|
-
|
|
121
|
-
worker = _worker;
|
|
122
|
-
taskID = this.workerNextTaskID ++;
|
|
123
|
-
|
|
124
|
-
return new Promise( ( resolve, reject ) => {
|
|
125
|
-
|
|
126
|
-
worker._callbacks[ taskID ] = { resolve, reject };
|
|
127
|
-
|
|
128
|
-
worker.postMessage( { type: 'decode', id: taskID, buffer }, [ buffer ] );
|
|
129
|
-
|
|
130
|
-
// this.debug();
|
|
131
|
-
|
|
132
|
-
} );
|
|
133
|
-
|
|
134
|
-
} )
|
|
135
|
-
.then( ( message ) => this._createGeometry( message.data ) )
|
|
136
|
-
.catch( e => {
|
|
137
|
-
|
|
138
|
-
throw e;
|
|
139
|
-
|
|
140
|
-
} );
|
|
141
|
-
|
|
142
|
-
// Remove task from the task list.
|
|
143
|
-
// Note: replaced '.finally()' with '.catch().then()' block - iOS 11 support (#19416)
|
|
144
|
-
objectPending
|
|
145
|
-
.catch( () => true )
|
|
146
|
-
.then( () => {
|
|
147
|
-
|
|
148
|
-
if ( worker && taskID ) {
|
|
149
|
-
|
|
150
|
-
this._releaseTask( worker, taskID );
|
|
151
|
-
|
|
152
|
-
//this.debug();
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
} );
|
|
157
|
-
|
|
158
|
-
// Cache the task result.
|
|
159
|
-
_taskCache.set( buffer, {
|
|
160
|
-
|
|
161
|
-
url: url,
|
|
162
|
-
promise: objectPending
|
|
163
|
-
|
|
164
|
-
} );
|
|
165
|
-
|
|
166
|
-
return objectPending;
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
parse( data, onLoad, onError ) {
|
|
171
|
-
|
|
172
|
-
this.decodeObjects( data, '' )
|
|
173
|
-
.then( result => {
|
|
174
|
-
|
|
175
|
-
result.userData.warnings = this.warnings;
|
|
176
|
-
onLoad( result );
|
|
177
|
-
|
|
178
|
-
} )
|
|
179
|
-
.catch( e => onError( e ) );
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
_compareMaterials( material ) {
|
|
184
|
-
|
|
185
|
-
const mat = {};
|
|
186
|
-
mat.name = material.name;
|
|
187
|
-
mat.color = {};
|
|
188
|
-
mat.color.r = material.color.r;
|
|
189
|
-
mat.color.g = material.color.g;
|
|
190
|
-
mat.color.b = material.color.b;
|
|
191
|
-
mat.type = material.type;
|
|
192
|
-
|
|
193
|
-
const json = JSON.stringify( mat );
|
|
194
|
-
|
|
195
|
-
for ( let i = 0; i < this.materials.length; i ++ ) {
|
|
196
|
-
|
|
197
|
-
const m = this.materials[ i ];
|
|
198
|
-
const _mat = {};
|
|
199
|
-
_mat.name = m.name;
|
|
200
|
-
_mat.color = {};
|
|
201
|
-
_mat.color.r = m.color.r;
|
|
202
|
-
_mat.color.g = m.color.g;
|
|
203
|
-
_mat.color.b = m.color.b;
|
|
204
|
-
_mat.type = m.type;
|
|
205
|
-
|
|
206
|
-
if ( JSON.stringify( _mat ) === json ) {
|
|
207
|
-
|
|
208
|
-
return m;
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
this.materials.push( material );
|
|
215
|
-
|
|
216
|
-
return material;
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
_createMaterial( material ) {
|
|
221
|
-
|
|
222
|
-
if ( material === undefined ) {
|
|
223
|
-
|
|
224
|
-
return new MeshStandardMaterial( {
|
|
225
|
-
color: new Color( 1, 1, 1 ),
|
|
226
|
-
metalness: 0.8,
|
|
227
|
-
name: Loader.DEFAULT_MATERIAL_NAME,
|
|
228
|
-
side: DoubleSide
|
|
229
|
-
} );
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const _diffuseColor = material.diffuseColor;
|
|
234
|
-
|
|
235
|
-
const diffusecolor = new Color( _diffuseColor.r / 255.0, _diffuseColor.g / 255.0, _diffuseColor.b / 255.0 );
|
|
236
|
-
|
|
237
|
-
if ( _diffuseColor.r === 0 && _diffuseColor.g === 0 && _diffuseColor.b === 0 ) {
|
|
238
|
-
|
|
239
|
-
diffusecolor.r = 1;
|
|
240
|
-
diffusecolor.g = 1;
|
|
241
|
-
diffusecolor.b = 1;
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// console.log( material );
|
|
246
|
-
|
|
247
|
-
const mat = new MeshStandardMaterial( {
|
|
248
|
-
color: diffusecolor,
|
|
249
|
-
name: material.name,
|
|
250
|
-
side: DoubleSide,
|
|
251
|
-
transparent: material.transparency > 0 ? true : false,
|
|
252
|
-
opacity: 1.0 - material.transparency
|
|
253
|
-
} );
|
|
254
|
-
|
|
255
|
-
const textureLoader = new TextureLoader();
|
|
256
|
-
|
|
257
|
-
for ( let i = 0; i < material.textures.length; i ++ ) {
|
|
258
|
-
|
|
259
|
-
const texture = material.textures[ i ];
|
|
260
|
-
|
|
261
|
-
if ( texture.image !== null ) {
|
|
262
|
-
|
|
263
|
-
const map = textureLoader.load( texture.image );
|
|
264
|
-
|
|
265
|
-
switch ( texture.type ) {
|
|
266
|
-
|
|
267
|
-
case 'Diffuse':
|
|
268
|
-
|
|
269
|
-
mat.map = map;
|
|
270
|
-
|
|
271
|
-
break;
|
|
272
|
-
|
|
273
|
-
case 'Bump':
|
|
274
|
-
|
|
275
|
-
mat.bumpMap = map;
|
|
276
|
-
|
|
277
|
-
break;
|
|
278
|
-
|
|
279
|
-
case 'Transparency':
|
|
280
|
-
|
|
281
|
-
mat.alphaMap = map;
|
|
282
|
-
mat.transparent = true;
|
|
283
|
-
|
|
284
|
-
break;
|
|
285
|
-
|
|
286
|
-
case 'Emap':
|
|
287
|
-
|
|
288
|
-
mat.envMap = map;
|
|
289
|
-
|
|
290
|
-
break;
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
map.wrapS = texture.wrapU === 0 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
295
|
-
map.wrapT = texture.wrapV === 0 ? RepeatWrapping : ClampToEdgeWrapping;
|
|
296
|
-
map.repeat.set( texture.repeat[ 0 ], texture.repeat[ 1 ] );
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return mat;
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
_createGeometry( data ) {
|
|
307
|
-
|
|
308
|
-
// console.log(data);
|
|
309
|
-
|
|
310
|
-
const object = new Object3D();
|
|
311
|
-
const instanceDefinitionObjects = [];
|
|
312
|
-
const instanceDefinitions = [];
|
|
313
|
-
const instanceReferences = [];
|
|
314
|
-
|
|
315
|
-
object.userData[ 'layers' ] = data.layers;
|
|
316
|
-
object.userData[ 'groups' ] = data.groups;
|
|
317
|
-
object.userData[ 'settings' ] = data.settings;
|
|
318
|
-
object.userData[ 'objectType' ] = 'File3dm';
|
|
319
|
-
object.userData[ 'materials' ] = null;
|
|
320
|
-
object.name = this.url;
|
|
321
|
-
|
|
322
|
-
let objects = data.objects;
|
|
323
|
-
const materials = data.materials;
|
|
324
|
-
|
|
325
|
-
for ( let i = 0; i < objects.length; i ++ ) {
|
|
326
|
-
|
|
327
|
-
const obj = objects[ i ];
|
|
328
|
-
const attributes = obj.attributes;
|
|
329
|
-
|
|
330
|
-
switch ( obj.objectType ) {
|
|
331
|
-
|
|
332
|
-
case 'InstanceDefinition':
|
|
333
|
-
|
|
334
|
-
instanceDefinitions.push( obj );
|
|
335
|
-
|
|
336
|
-
break;
|
|
337
|
-
|
|
338
|
-
case 'InstanceReference':
|
|
339
|
-
|
|
340
|
-
instanceReferences.push( obj );
|
|
341
|
-
|
|
342
|
-
break;
|
|
343
|
-
|
|
344
|
-
default:
|
|
345
|
-
|
|
346
|
-
let _object;
|
|
347
|
-
|
|
348
|
-
if ( attributes.materialIndex >= 0 ) {
|
|
349
|
-
|
|
350
|
-
const rMaterial = materials[ attributes.materialIndex ];
|
|
351
|
-
let material = this._createMaterial( rMaterial );
|
|
352
|
-
material = this._compareMaterials( material );
|
|
353
|
-
_object = this._createObject( obj, material );
|
|
354
|
-
|
|
355
|
-
} else {
|
|
356
|
-
|
|
357
|
-
const material = this._createMaterial();
|
|
358
|
-
_object = this._createObject( obj, material );
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
if ( _object === undefined ) {
|
|
363
|
-
|
|
364
|
-
continue;
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const layer = data.layers[ attributes.layerIndex ];
|
|
369
|
-
|
|
370
|
-
_object.visible = layer ? data.layers[ attributes.layerIndex ].visible : true;
|
|
371
|
-
|
|
372
|
-
if ( attributes.isInstanceDefinitionObject ) {
|
|
373
|
-
|
|
374
|
-
instanceDefinitionObjects.push( _object );
|
|
375
|
-
|
|
376
|
-
} else {
|
|
377
|
-
|
|
378
|
-
object.add( _object );
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
break;
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
for ( let i = 0; i < instanceDefinitions.length; i ++ ) {
|
|
389
|
-
|
|
390
|
-
const iDef = instanceDefinitions[ i ];
|
|
391
|
-
|
|
392
|
-
objects = [];
|
|
393
|
-
|
|
394
|
-
for ( let j = 0; j < iDef.attributes.objectIds.length; j ++ ) {
|
|
395
|
-
|
|
396
|
-
const objId = iDef.attributes.objectIds[ j ];
|
|
397
|
-
|
|
398
|
-
for ( let p = 0; p < instanceDefinitionObjects.length; p ++ ) {
|
|
399
|
-
|
|
400
|
-
const idoId = instanceDefinitionObjects[ p ].userData.attributes.id;
|
|
401
|
-
|
|
402
|
-
if ( objId === idoId ) {
|
|
403
|
-
|
|
404
|
-
objects.push( instanceDefinitionObjects[ p ] );
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Currently clones geometry and does not take advantage of instancing
|
|
413
|
-
|
|
414
|
-
for ( let j = 0; j < instanceReferences.length; j ++ ) {
|
|
415
|
-
|
|
416
|
-
const iRef = instanceReferences[ j ];
|
|
417
|
-
|
|
418
|
-
if ( iRef.geometry.parentIdefId === iDef.attributes.id ) {
|
|
419
|
-
|
|
420
|
-
const iRefObject = new Object3D();
|
|
421
|
-
const xf = iRef.geometry.xform.array;
|
|
422
|
-
|
|
423
|
-
const matrix = new Matrix4();
|
|
424
|
-
matrix.set( ...xf );
|
|
425
|
-
|
|
426
|
-
iRefObject.applyMatrix4( matrix );
|
|
427
|
-
|
|
428
|
-
for ( let p = 0; p < objects.length; p ++ ) {
|
|
429
|
-
|
|
430
|
-
iRefObject.add( objects[ p ].clone( true ) );
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
object.add( iRefObject );
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
object.userData[ 'materials' ] = this.materials;
|
|
443
|
-
return object;
|
|
444
|
-
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
_createObject( obj, mat ) {
|
|
448
|
-
|
|
449
|
-
const loader = new BufferGeometryLoader();
|
|
450
|
-
|
|
451
|
-
const attributes = obj.attributes;
|
|
452
|
-
|
|
453
|
-
let geometry, material, _color, color;
|
|
454
|
-
|
|
455
|
-
switch ( obj.objectType ) {
|
|
456
|
-
|
|
457
|
-
case 'Point':
|
|
458
|
-
case 'PointSet':
|
|
459
|
-
|
|
460
|
-
geometry = loader.parse( obj.geometry );
|
|
461
|
-
|
|
462
|
-
if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
|
|
463
|
-
|
|
464
|
-
material = new PointsMaterial( { vertexColors: true, sizeAttenuation: false, size: 2 } );
|
|
465
|
-
|
|
466
|
-
} else {
|
|
467
|
-
|
|
468
|
-
_color = attributes.drawColor;
|
|
469
|
-
color = new Color( _color.r / 255.0, _color.g / 255.0, _color.b / 255.0 );
|
|
470
|
-
material = new PointsMaterial( { color: color, sizeAttenuation: false, size: 2 } );
|
|
471
|
-
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
material = this._compareMaterials( material );
|
|
475
|
-
|
|
476
|
-
const points = new Points( geometry, material );
|
|
477
|
-
points.userData[ 'attributes' ] = attributes;
|
|
478
|
-
points.userData[ 'objectType' ] = obj.objectType;
|
|
479
|
-
|
|
480
|
-
if ( attributes.name ) {
|
|
481
|
-
|
|
482
|
-
points.name = attributes.name;
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return points;
|
|
487
|
-
|
|
488
|
-
case 'Mesh':
|
|
489
|
-
case 'Extrusion':
|
|
490
|
-
case 'SubD':
|
|
491
|
-
case 'Brep':
|
|
492
|
-
|
|
493
|
-
if ( obj.geometry === null ) return;
|
|
494
|
-
|
|
495
|
-
geometry = loader.parse( obj.geometry );
|
|
496
|
-
|
|
497
|
-
if ( geometry.attributes.hasOwnProperty( 'color' ) ) {
|
|
498
|
-
|
|
499
|
-
mat.vertexColors = true;
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
if ( mat === null ) {
|
|
504
|
-
|
|
505
|
-
mat = this._createMaterial();
|
|
506
|
-
mat = this._compareMaterials( mat );
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
const mesh = new Mesh( geometry, mat );
|
|
511
|
-
mesh.castShadow = attributes.castsShadows;
|
|
512
|
-
mesh.receiveShadow = attributes.receivesShadows;
|
|
513
|
-
mesh.userData[ 'attributes' ] = attributes;
|
|
514
|
-
mesh.userData[ 'objectType' ] = obj.objectType;
|
|
515
|
-
|
|
516
|
-
if ( attributes.name ) {
|
|
517
|
-
|
|
518
|
-
mesh.name = attributes.name;
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
return mesh;
|
|
523
|
-
|
|
524
|
-
case 'Curve':
|
|
525
|
-
|
|
526
|
-
geometry = loader.parse( obj.geometry );
|
|
527
|
-
|
|
528
|
-
_color = attributes.drawColor;
|
|
529
|
-
color = new Color( _color.r / 255.0, _color.g / 255.0, _color.b / 255.0 );
|
|
530
|
-
|
|
531
|
-
material = new LineBasicMaterial( { color: color } );
|
|
532
|
-
material = this._compareMaterials( material );
|
|
533
|
-
|
|
534
|
-
const lines = new Line( geometry, material );
|
|
535
|
-
lines.userData[ 'attributes' ] = attributes;
|
|
536
|
-
lines.userData[ 'objectType' ] = obj.objectType;
|
|
537
|
-
|
|
538
|
-
if ( attributes.name ) {
|
|
539
|
-
|
|
540
|
-
lines.name = attributes.name;
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
return lines;
|
|
545
|
-
|
|
546
|
-
case 'TextDot':
|
|
547
|
-
|
|
548
|
-
geometry = obj.geometry;
|
|
549
|
-
|
|
550
|
-
const ctx = document.createElement( 'canvas' ).getContext( '2d' );
|
|
551
|
-
const font = `${geometry.fontHeight}px ${geometry.fontFace}`;
|
|
552
|
-
ctx.font = font;
|
|
553
|
-
const width = ctx.measureText( geometry.text ).width + 10;
|
|
554
|
-
const height = geometry.fontHeight + 10;
|
|
555
|
-
|
|
556
|
-
const r = window.devicePixelRatio;
|
|
557
|
-
|
|
558
|
-
ctx.canvas.width = width * r;
|
|
559
|
-
ctx.canvas.height = height * r;
|
|
560
|
-
ctx.canvas.style.width = width + 'px';
|
|
561
|
-
ctx.canvas.style.height = height + 'px';
|
|
562
|
-
ctx.setTransform( r, 0, 0, r, 0, 0 );
|
|
563
|
-
|
|
564
|
-
ctx.font = font;
|
|
565
|
-
ctx.textBaseline = 'middle';
|
|
566
|
-
ctx.textAlign = 'center';
|
|
567
|
-
color = attributes.drawColor;
|
|
568
|
-
ctx.fillStyle = `rgba(${color.r},${color.g},${color.b},${color.a})`;
|
|
569
|
-
ctx.fillRect( 0, 0, width, height );
|
|
570
|
-
ctx.fillStyle = 'white';
|
|
571
|
-
ctx.fillText( geometry.text, width / 2, height / 2 );
|
|
572
|
-
|
|
573
|
-
const texture = new CanvasTexture( ctx.canvas );
|
|
574
|
-
texture.minFilter = LinearFilter;
|
|
575
|
-
texture.wrapS = ClampToEdgeWrapping;
|
|
576
|
-
texture.wrapT = ClampToEdgeWrapping;
|
|
577
|
-
|
|
578
|
-
material = new SpriteMaterial( { map: texture, depthTest: false } );
|
|
579
|
-
const sprite = new Sprite( material );
|
|
580
|
-
sprite.position.set( geometry.point[ 0 ], geometry.point[ 1 ], geometry.point[ 2 ] );
|
|
581
|
-
sprite.scale.set( width / 10, height / 10, 1.0 );
|
|
582
|
-
|
|
583
|
-
sprite.userData[ 'attributes' ] = attributes;
|
|
584
|
-
sprite.userData[ 'objectType' ] = obj.objectType;
|
|
585
|
-
|
|
586
|
-
if ( attributes.name ) {
|
|
587
|
-
|
|
588
|
-
sprite.name = attributes.name;
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
return sprite;
|
|
593
|
-
|
|
594
|
-
case 'Light':
|
|
595
|
-
|
|
596
|
-
geometry = obj.geometry;
|
|
597
|
-
|
|
598
|
-
let light;
|
|
599
|
-
|
|
600
|
-
switch ( geometry.lightStyle.name ) {
|
|
601
|
-
|
|
602
|
-
case 'LightStyle_WorldPoint':
|
|
603
|
-
|
|
604
|
-
light = new PointLight();
|
|
605
|
-
light.castShadow = attributes.castsShadows;
|
|
606
|
-
light.position.set( geometry.location[ 0 ], geometry.location[ 1 ], geometry.location[ 2 ] );
|
|
607
|
-
light.shadow.normalBias = 0.1;
|
|
608
|
-
|
|
609
|
-
break;
|
|
610
|
-
|
|
611
|
-
case 'LightStyle_WorldSpot':
|
|
612
|
-
|
|
613
|
-
light = new SpotLight();
|
|
614
|
-
light.castShadow = attributes.castsShadows;
|
|
615
|
-
light.position.set( geometry.location[ 0 ], geometry.location[ 1 ], geometry.location[ 2 ] );
|
|
616
|
-
light.target.position.set( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
|
|
617
|
-
light.angle = geometry.spotAngleRadians;
|
|
618
|
-
light.shadow.normalBias = 0.1;
|
|
619
|
-
|
|
620
|
-
break;
|
|
621
|
-
|
|
622
|
-
case 'LightStyle_WorldRectangular':
|
|
623
|
-
|
|
624
|
-
light = new RectAreaLight();
|
|
625
|
-
const width = Math.abs( geometry.width[ 2 ] );
|
|
626
|
-
const height = Math.abs( geometry.length[ 0 ] );
|
|
627
|
-
light.position.set( geometry.location[ 0 ] - ( height / 2 ), geometry.location[ 1 ], geometry.location[ 2 ] - ( width / 2 ) );
|
|
628
|
-
light.height = height;
|
|
629
|
-
light.width = width;
|
|
630
|
-
light.lookAt( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
|
|
631
|
-
|
|
632
|
-
break;
|
|
633
|
-
|
|
634
|
-
case 'LightStyle_WorldDirectional':
|
|
635
|
-
|
|
636
|
-
light = new DirectionalLight();
|
|
637
|
-
light.castShadow = attributes.castsShadows;
|
|
638
|
-
light.position.set( geometry.location[ 0 ], geometry.location[ 1 ], geometry.location[ 2 ] );
|
|
639
|
-
light.target.position.set( geometry.direction[ 0 ], geometry.direction[ 1 ], geometry.direction[ 2 ] );
|
|
640
|
-
light.shadow.normalBias = 0.1;
|
|
641
|
-
|
|
642
|
-
break;
|
|
643
|
-
|
|
644
|
-
case 'LightStyle_WorldLinear':
|
|
645
|
-
// not conversion exists, warning has already been printed to the console
|
|
646
|
-
break;
|
|
647
|
-
|
|
648
|
-
default:
|
|
649
|
-
break;
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if ( light ) {
|
|
654
|
-
|
|
655
|
-
light.intensity = geometry.intensity;
|
|
656
|
-
_color = geometry.diffuse;
|
|
657
|
-
color = new Color( _color.r / 255.0, _color.g / 255.0, _color.b / 255.0 );
|
|
658
|
-
light.color = color;
|
|
659
|
-
light.userData[ 'attributes' ] = attributes;
|
|
660
|
-
light.userData[ 'objectType' ] = obj.objectType;
|
|
661
|
-
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
return light;
|
|
665
|
-
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
_initLibrary() {
|
|
671
|
-
|
|
672
|
-
if ( ! this.libraryPending ) {
|
|
673
|
-
|
|
674
|
-
// Load rhino3dm wrapper.
|
|
675
|
-
const jsLoader = new FileLoader( this.manager );
|
|
676
|
-
jsLoader.setPath( this.libraryPath );
|
|
677
|
-
const jsContent = new Promise( ( resolve, reject ) => {
|
|
678
|
-
|
|
679
|
-
jsLoader.load( 'rhino3dm.js', resolve, undefined, reject );
|
|
680
|
-
|
|
681
|
-
} );
|
|
682
|
-
|
|
683
|
-
// Load rhino3dm WASM binary.
|
|
684
|
-
const binaryLoader = new FileLoader( this.manager );
|
|
685
|
-
binaryLoader.setPath( this.libraryPath );
|
|
686
|
-
binaryLoader.setResponseType( 'arraybuffer' );
|
|
687
|
-
const binaryContent = new Promise( ( resolve, reject ) => {
|
|
688
|
-
|
|
689
|
-
binaryLoader.load( 'rhino3dm.wasm', resolve, undefined, reject );
|
|
690
|
-
|
|
691
|
-
} );
|
|
692
|
-
|
|
693
|
-
this.libraryPending = Promise.all( [ jsContent, binaryContent ] )
|
|
694
|
-
.then( ( [ jsContent, binaryContent ] ) => {
|
|
695
|
-
|
|
696
|
-
//this.libraryBinary = binaryContent;
|
|
697
|
-
this.libraryConfig.wasmBinary = binaryContent;
|
|
698
|
-
|
|
699
|
-
const fn = Rhino3dmWorker.toString();
|
|
700
|
-
|
|
701
|
-
const body = [
|
|
702
|
-
'/* rhino3dm.js */',
|
|
703
|
-
jsContent,
|
|
704
|
-
'/* worker */',
|
|
705
|
-
fn.substring( fn.indexOf( '{' ) + 1, fn.lastIndexOf( '}' ) )
|
|
706
|
-
].join( '\n' );
|
|
707
|
-
|
|
708
|
-
this.workerSourceURL = URL.createObjectURL( new Blob( [ body ] ) );
|
|
709
|
-
|
|
710
|
-
} );
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
return this.libraryPending;
|
|
715
|
-
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
_getWorker( taskCost ) {
|
|
719
|
-
|
|
720
|
-
return this._initLibrary().then( () => {
|
|
721
|
-
|
|
722
|
-
if ( this.workerPool.length < this.workerLimit ) {
|
|
723
|
-
|
|
724
|
-
const worker = new Worker( this.workerSourceURL );
|
|
725
|
-
|
|
726
|
-
worker._callbacks = {};
|
|
727
|
-
worker._taskCosts = {};
|
|
728
|
-
worker._taskLoad = 0;
|
|
729
|
-
|
|
730
|
-
worker.postMessage( {
|
|
731
|
-
type: 'init',
|
|
732
|
-
libraryConfig: this.libraryConfig
|
|
733
|
-
} );
|
|
734
|
-
|
|
735
|
-
worker.onmessage = e => {
|
|
736
|
-
|
|
737
|
-
const message = e.data;
|
|
738
|
-
|
|
739
|
-
switch ( message.type ) {
|
|
740
|
-
|
|
741
|
-
case 'warning':
|
|
742
|
-
this.warnings.push( message.data );
|
|
743
|
-
console.warn( message.data );
|
|
744
|
-
break;
|
|
745
|
-
|
|
746
|
-
case 'decode':
|
|
747
|
-
worker._callbacks[ message.id ].resolve( message );
|
|
748
|
-
break;
|
|
749
|
-
|
|
750
|
-
case 'error':
|
|
751
|
-
worker._callbacks[ message.id ].reject( message );
|
|
752
|
-
break;
|
|
753
|
-
|
|
754
|
-
default:
|
|
755
|
-
console.error( 'THREE.Rhino3dmLoader: Unexpected message, "' + message.type + '"' );
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
};
|
|
760
|
-
|
|
761
|
-
this.workerPool.push( worker );
|
|
762
|
-
|
|
763
|
-
} else {
|
|
764
|
-
|
|
765
|
-
this.workerPool.sort( function ( a, b ) {
|
|
766
|
-
|
|
767
|
-
return a._taskLoad > b._taskLoad ? - 1 : 1;
|
|
768
|
-
|
|
769
|
-
} );
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
const worker = this.workerPool[ this.workerPool.length - 1 ];
|
|
774
|
-
|
|
775
|
-
worker._taskLoad += taskCost;
|
|
776
|
-
|
|
777
|
-
return worker;
|
|
778
|
-
|
|
779
|
-
} );
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
_releaseTask( worker, taskID ) {
|
|
784
|
-
|
|
785
|
-
worker._taskLoad -= worker._taskCosts[ taskID ];
|
|
786
|
-
delete worker._callbacks[ taskID ];
|
|
787
|
-
delete worker._taskCosts[ taskID ];
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
dispose() {
|
|
792
|
-
|
|
793
|
-
for ( let i = 0; i < this.workerPool.length; ++ i ) {
|
|
794
|
-
|
|
795
|
-
this.workerPool[ i ].terminate();
|
|
796
|
-
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
this.workerPool.length = 0;
|
|
800
|
-
|
|
801
|
-
return this;
|
|
802
|
-
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
/* WEB WORKER */
|
|
808
|
-
|
|
809
|
-
function Rhino3dmWorker() {
|
|
810
|
-
|
|
811
|
-
let libraryPending;
|
|
812
|
-
let libraryConfig;
|
|
813
|
-
let rhino;
|
|
814
|
-
let taskID;
|
|
815
|
-
|
|
816
|
-
onmessage = function ( e ) {
|
|
817
|
-
|
|
818
|
-
const message = e.data;
|
|
819
|
-
|
|
820
|
-
switch ( message.type ) {
|
|
821
|
-
|
|
822
|
-
case 'init':
|
|
823
|
-
|
|
824
|
-
// console.log(message)
|
|
825
|
-
libraryConfig = message.libraryConfig;
|
|
826
|
-
const wasmBinary = libraryConfig.wasmBinary;
|
|
827
|
-
let RhinoModule;
|
|
828
|
-
libraryPending = new Promise( function ( resolve ) {
|
|
829
|
-
|
|
830
|
-
/* Like Basis Loader */
|
|
831
|
-
RhinoModule = { wasmBinary, onRuntimeInitialized: resolve };
|
|
832
|
-
|
|
833
|
-
rhino3dm( RhinoModule ); // eslint-disable-line no-undef
|
|
834
|
-
|
|
835
|
-
} ).then( () => {
|
|
836
|
-
|
|
837
|
-
rhino = RhinoModule;
|
|
838
|
-
|
|
839
|
-
} );
|
|
840
|
-
|
|
841
|
-
break;
|
|
842
|
-
|
|
843
|
-
case 'decode':
|
|
844
|
-
|
|
845
|
-
taskID = message.id;
|
|
846
|
-
const buffer = message.buffer;
|
|
847
|
-
libraryPending.then( () => {
|
|
848
|
-
|
|
849
|
-
try {
|
|
850
|
-
|
|
851
|
-
const data = decodeObjects( rhino, buffer );
|
|
852
|
-
self.postMessage( { type: 'decode', id: message.id, data } );
|
|
853
|
-
|
|
854
|
-
} catch ( error ) {
|
|
855
|
-
|
|
856
|
-
self.postMessage( { type: 'error', id: message.id, error } );
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
} );
|
|
861
|
-
|
|
862
|
-
break;
|
|
863
|
-
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
};
|
|
867
|
-
|
|
868
|
-
function decodeObjects( rhino, buffer ) {
|
|
869
|
-
|
|
870
|
-
const arr = new Uint8Array( buffer );
|
|
871
|
-
const doc = rhino.File3dm.fromByteArray( arr );
|
|
872
|
-
|
|
873
|
-
const objects = [];
|
|
874
|
-
const materials = [];
|
|
875
|
-
const layers = [];
|
|
876
|
-
const views = [];
|
|
877
|
-
const namedViews = [];
|
|
878
|
-
const groups = [];
|
|
879
|
-
const strings = [];
|
|
880
|
-
|
|
881
|
-
//Handle objects
|
|
882
|
-
|
|
883
|
-
const objs = doc.objects();
|
|
884
|
-
const cnt = objs.count;
|
|
885
|
-
|
|
886
|
-
for ( let i = 0; i < cnt; i ++ ) {
|
|
887
|
-
|
|
888
|
-
const _object = objs.get( i );
|
|
889
|
-
|
|
890
|
-
const object = extractObjectData( _object, doc );
|
|
891
|
-
|
|
892
|
-
_object.delete();
|
|
893
|
-
|
|
894
|
-
if ( object ) {
|
|
895
|
-
|
|
896
|
-
objects.push( object );
|
|
897
|
-
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
// Handle instance definitions
|
|
903
|
-
// console.log( `Instance Definitions Count: ${doc.instanceDefinitions().count()}` );
|
|
904
|
-
|
|
905
|
-
for ( let i = 0; i < doc.instanceDefinitions().count(); i ++ ) {
|
|
906
|
-
|
|
907
|
-
const idef = doc.instanceDefinitions().get( i );
|
|
908
|
-
const idefAttributes = extractProperties( idef );
|
|
909
|
-
idefAttributes.objectIds = idef.getObjectIds();
|
|
910
|
-
|
|
911
|
-
objects.push( { geometry: null, attributes: idefAttributes, objectType: 'InstanceDefinition' } );
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
// Handle materials
|
|
916
|
-
|
|
917
|
-
const textureTypes = [
|
|
918
|
-
// rhino.TextureType.Bitmap,
|
|
919
|
-
rhino.TextureType.Diffuse,
|
|
920
|
-
rhino.TextureType.Bump,
|
|
921
|
-
rhino.TextureType.Transparency,
|
|
922
|
-
rhino.TextureType.Opacity,
|
|
923
|
-
rhino.TextureType.Emap
|
|
924
|
-
];
|
|
925
|
-
|
|
926
|
-
const pbrTextureTypes = [
|
|
927
|
-
rhino.TextureType.PBR_BaseColor,
|
|
928
|
-
rhino.TextureType.PBR_Subsurface,
|
|
929
|
-
rhino.TextureType.PBR_SubsurfaceScattering,
|
|
930
|
-
rhino.TextureType.PBR_SubsurfaceScatteringRadius,
|
|
931
|
-
rhino.TextureType.PBR_Metallic,
|
|
932
|
-
rhino.TextureType.PBR_Specular,
|
|
933
|
-
rhino.TextureType.PBR_SpecularTint,
|
|
934
|
-
rhino.TextureType.PBR_Roughness,
|
|
935
|
-
rhino.TextureType.PBR_Anisotropic,
|
|
936
|
-
rhino.TextureType.PBR_Anisotropic_Rotation,
|
|
937
|
-
rhino.TextureType.PBR_Sheen,
|
|
938
|
-
rhino.TextureType.PBR_SheenTint,
|
|
939
|
-
rhino.TextureType.PBR_Clearcoat,
|
|
940
|
-
rhino.TextureType.PBR_ClearcoatBump,
|
|
941
|
-
rhino.TextureType.PBR_ClearcoatRoughness,
|
|
942
|
-
rhino.TextureType.PBR_OpacityIor,
|
|
943
|
-
rhino.TextureType.PBR_OpacityRoughness,
|
|
944
|
-
rhino.TextureType.PBR_Emission,
|
|
945
|
-
rhino.TextureType.PBR_AmbientOcclusion,
|
|
946
|
-
rhino.TextureType.PBR_Displacement
|
|
947
|
-
];
|
|
948
|
-
|
|
949
|
-
for ( let i = 0; i < doc.materials().count(); i ++ ) {
|
|
950
|
-
|
|
951
|
-
const _material = doc.materials().get( i );
|
|
952
|
-
const _pbrMaterial = _material.physicallyBased();
|
|
953
|
-
|
|
954
|
-
let material = extractProperties( _material );
|
|
955
|
-
|
|
956
|
-
const textures = [];
|
|
957
|
-
|
|
958
|
-
for ( let j = 0; j < textureTypes.length; j ++ ) {
|
|
959
|
-
|
|
960
|
-
const _texture = _material.getTexture( textureTypes[ j ] );
|
|
961
|
-
if ( _texture ) {
|
|
962
|
-
|
|
963
|
-
let textureType = textureTypes[ j ].constructor.name;
|
|
964
|
-
textureType = textureType.substring( 12, textureType.length );
|
|
965
|
-
const texture = { type: textureType };
|
|
966
|
-
|
|
967
|
-
const image = doc.getEmbeddedFileAsBase64( _texture.fileName );
|
|
968
|
-
|
|
969
|
-
texture.wrapU = _texture.wrapU;
|
|
970
|
-
texture.wrapV = _texture.wrapV;
|
|
971
|
-
texture.wrapW = _texture.wrapW;
|
|
972
|
-
const uvw = _texture.uvwTransform.toFloatArray( true );
|
|
973
|
-
texture.repeat = [ uvw[ 0 ], uvw[ 5 ] ];
|
|
974
|
-
|
|
975
|
-
if ( image ) {
|
|
976
|
-
|
|
977
|
-
texture.image = 'data:image/png;base64,' + image;
|
|
978
|
-
|
|
979
|
-
} else {
|
|
980
|
-
|
|
981
|
-
self.postMessage( { type: 'warning', id: taskID, data: {
|
|
982
|
-
message: `THREE.3DMLoader: Image for ${textureType} texture not embedded in file.`,
|
|
983
|
-
type: 'missing resource'
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
} );
|
|
987
|
-
|
|
988
|
-
texture.image = null;
|
|
989
|
-
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
textures.push( texture );
|
|
993
|
-
|
|
994
|
-
_texture.delete();
|
|
995
|
-
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
material.textures = textures;
|
|
1001
|
-
|
|
1002
|
-
if ( _pbrMaterial.supported ) {
|
|
1003
|
-
|
|
1004
|
-
for ( let j = 0; j < pbrTextureTypes.length; j ++ ) {
|
|
1005
|
-
|
|
1006
|
-
const _texture = _material.getTexture( pbrTextureTypes[ j ] );
|
|
1007
|
-
if ( _texture ) {
|
|
1008
|
-
|
|
1009
|
-
const image = doc.getEmbeddedFileAsBase64( _texture.fileName );
|
|
1010
|
-
let textureType = pbrTextureTypes[ j ].constructor.name;
|
|
1011
|
-
textureType = textureType.substring( 12, textureType.length );
|
|
1012
|
-
const texture = { type: textureType, image: 'data:image/png;base64,' + image };
|
|
1013
|
-
textures.push( texture );
|
|
1014
|
-
|
|
1015
|
-
_texture.delete();
|
|
1016
|
-
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
const pbMaterialProperties = extractProperties( _material.physicallyBased() );
|
|
1022
|
-
|
|
1023
|
-
material = Object.assign( pbMaterialProperties, material );
|
|
1024
|
-
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
materials.push( material );
|
|
1028
|
-
|
|
1029
|
-
_material.delete();
|
|
1030
|
-
_pbrMaterial.delete();
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
// Handle layers
|
|
1035
|
-
|
|
1036
|
-
for ( let i = 0; i < doc.layers().count(); i ++ ) {
|
|
1037
|
-
|
|
1038
|
-
const _layer = doc.layers().get( i );
|
|
1039
|
-
const layer = extractProperties( _layer );
|
|
1040
|
-
|
|
1041
|
-
layers.push( layer );
|
|
1042
|
-
|
|
1043
|
-
_layer.delete();
|
|
1044
|
-
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
// Handle views
|
|
1048
|
-
|
|
1049
|
-
for ( let i = 0; i < doc.views().count(); i ++ ) {
|
|
1050
|
-
|
|
1051
|
-
const _view = doc.views().get( i );
|
|
1052
|
-
const view = extractProperties( _view );
|
|
1053
|
-
|
|
1054
|
-
views.push( view );
|
|
1055
|
-
|
|
1056
|
-
_view.delete();
|
|
1057
|
-
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
// Handle named views
|
|
1061
|
-
|
|
1062
|
-
for ( let i = 0; i < doc.namedViews().count(); i ++ ) {
|
|
1063
|
-
|
|
1064
|
-
const _namedView = doc.namedViews().get( i );
|
|
1065
|
-
const namedView = extractProperties( _namedView );
|
|
1066
|
-
|
|
1067
|
-
namedViews.push( namedView );
|
|
1068
|
-
|
|
1069
|
-
_namedView.delete();
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// Handle groups
|
|
1074
|
-
|
|
1075
|
-
for ( let i = 0; i < doc.groups().count(); i ++ ) {
|
|
1076
|
-
|
|
1077
|
-
const _group = doc.groups().get( i );
|
|
1078
|
-
const group = extractProperties( _group );
|
|
1079
|
-
|
|
1080
|
-
groups.push( group );
|
|
1081
|
-
|
|
1082
|
-
_group.delete();
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
// Handle settings
|
|
1087
|
-
|
|
1088
|
-
const settings = extractProperties( doc.settings() );
|
|
1089
|
-
|
|
1090
|
-
//TODO: Handle other document stuff like dimstyles, instance definitions, bitmaps etc.
|
|
1091
|
-
|
|
1092
|
-
// Handle dimstyles
|
|
1093
|
-
// console.log( `Dimstyle Count: ${doc.dimstyles().count()}` );
|
|
1094
|
-
|
|
1095
|
-
// Handle bitmaps
|
|
1096
|
-
// console.log( `Bitmap Count: ${doc.bitmaps().count()}` );
|
|
1097
|
-
|
|
1098
|
-
// Handle strings
|
|
1099
|
-
// console.log( `Document Strings Count: ${doc.strings().count()}` );
|
|
1100
|
-
// Note: doc.strings().documentUserTextCount() counts any doc.strings defined in a section
|
|
1101
|
-
//console.log( `Document User Text Count: ${doc.strings().documentUserTextCount()}` );
|
|
1102
|
-
|
|
1103
|
-
const strings_count = doc.strings().count();
|
|
1104
|
-
|
|
1105
|
-
for ( let i = 0; i < strings_count; i ++ ) {
|
|
1106
|
-
|
|
1107
|
-
strings.push( doc.strings().get( i ) );
|
|
1108
|
-
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
doc.delete();
|
|
1112
|
-
|
|
1113
|
-
return { objects, materials, layers, views, namedViews, groups, strings, settings };
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
function extractObjectData( object, doc ) {
|
|
1118
|
-
|
|
1119
|
-
const _geometry = object.geometry();
|
|
1120
|
-
const _attributes = object.attributes();
|
|
1121
|
-
let objectType = _geometry.objectType;
|
|
1122
|
-
let geometry, attributes, position, data, mesh;
|
|
1123
|
-
|
|
1124
|
-
// skip instance definition objects
|
|
1125
|
-
//if( _attributes.isInstanceDefinitionObject ) { continue; }
|
|
1126
|
-
|
|
1127
|
-
// TODO: handle other geometry types
|
|
1128
|
-
switch ( objectType ) {
|
|
1129
|
-
|
|
1130
|
-
case rhino.ObjectType.Curve:
|
|
1131
|
-
|
|
1132
|
-
const pts = curveToPoints( _geometry, 100 );
|
|
1133
|
-
|
|
1134
|
-
position = {};
|
|
1135
|
-
attributes = {};
|
|
1136
|
-
data = {};
|
|
1137
|
-
|
|
1138
|
-
position.itemSize = 3;
|
|
1139
|
-
position.type = 'Float32Array';
|
|
1140
|
-
position.array = [];
|
|
1141
|
-
|
|
1142
|
-
for ( let j = 0; j < pts.length; j ++ ) {
|
|
1143
|
-
|
|
1144
|
-
position.array.push( pts[ j ][ 0 ] );
|
|
1145
|
-
position.array.push( pts[ j ][ 1 ] );
|
|
1146
|
-
position.array.push( pts[ j ][ 2 ] );
|
|
1147
|
-
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
attributes.position = position;
|
|
1151
|
-
data.attributes = attributes;
|
|
1152
|
-
|
|
1153
|
-
geometry = { data };
|
|
1154
|
-
|
|
1155
|
-
break;
|
|
1156
|
-
|
|
1157
|
-
case rhino.ObjectType.Point:
|
|
1158
|
-
|
|
1159
|
-
const pt = _geometry.location;
|
|
1160
|
-
|
|
1161
|
-
position = {};
|
|
1162
|
-
const color = {};
|
|
1163
|
-
attributes = {};
|
|
1164
|
-
data = {};
|
|
1165
|
-
|
|
1166
|
-
position.itemSize = 3;
|
|
1167
|
-
position.type = 'Float32Array';
|
|
1168
|
-
position.array = [ pt[ 0 ], pt[ 1 ], pt[ 2 ] ];
|
|
1169
|
-
|
|
1170
|
-
const _color = _attributes.drawColor( doc );
|
|
1171
|
-
|
|
1172
|
-
color.itemSize = 3;
|
|
1173
|
-
color.type = 'Float32Array';
|
|
1174
|
-
color.array = [ _color.r / 255.0, _color.g / 255.0, _color.b / 255.0 ];
|
|
1175
|
-
|
|
1176
|
-
attributes.position = position;
|
|
1177
|
-
attributes.color = color;
|
|
1178
|
-
data.attributes = attributes;
|
|
1179
|
-
|
|
1180
|
-
geometry = { data };
|
|
1181
|
-
|
|
1182
|
-
break;
|
|
1183
|
-
|
|
1184
|
-
case rhino.ObjectType.PointSet:
|
|
1185
|
-
case rhino.ObjectType.Mesh:
|
|
1186
|
-
|
|
1187
|
-
geometry = _geometry.toThreejsJSON();
|
|
1188
|
-
|
|
1189
|
-
break;
|
|
1190
|
-
|
|
1191
|
-
case rhino.ObjectType.Brep:
|
|
1192
|
-
|
|
1193
|
-
const faces = _geometry.faces();
|
|
1194
|
-
mesh = new rhino.Mesh();
|
|
1195
|
-
|
|
1196
|
-
for ( let faceIndex = 0; faceIndex < faces.count; faceIndex ++ ) {
|
|
1197
|
-
|
|
1198
|
-
const face = faces.get( faceIndex );
|
|
1199
|
-
const _mesh = face.getMesh( rhino.MeshType.Any );
|
|
1200
|
-
|
|
1201
|
-
if ( _mesh ) {
|
|
1202
|
-
|
|
1203
|
-
mesh.append( _mesh );
|
|
1204
|
-
_mesh.delete();
|
|
1205
|
-
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
face.delete();
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
if ( mesh.faces().count > 0 ) {
|
|
1213
|
-
|
|
1214
|
-
mesh.compact();
|
|
1215
|
-
geometry = mesh.toThreejsJSON();
|
|
1216
|
-
faces.delete();
|
|
1217
|
-
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
mesh.delete();
|
|
1221
|
-
|
|
1222
|
-
break;
|
|
1223
|
-
|
|
1224
|
-
case rhino.ObjectType.Extrusion:
|
|
1225
|
-
|
|
1226
|
-
mesh = _geometry.getMesh( rhino.MeshType.Any );
|
|
1227
|
-
|
|
1228
|
-
if ( mesh ) {
|
|
1229
|
-
|
|
1230
|
-
geometry = mesh.toThreejsJSON();
|
|
1231
|
-
mesh.delete();
|
|
1232
|
-
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
break;
|
|
1236
|
-
|
|
1237
|
-
case rhino.ObjectType.TextDot:
|
|
1238
|
-
|
|
1239
|
-
geometry = extractProperties( _geometry );
|
|
1240
|
-
|
|
1241
|
-
break;
|
|
1242
|
-
|
|
1243
|
-
case rhino.ObjectType.Light:
|
|
1244
|
-
|
|
1245
|
-
geometry = extractProperties( _geometry );
|
|
1246
|
-
|
|
1247
|
-
if ( geometry.lightStyle.name === 'LightStyle_WorldLinear' ) {
|
|
1248
|
-
|
|
1249
|
-
self.postMessage( { type: 'warning', id: taskID, data: {
|
|
1250
|
-
message: `THREE.3DMLoader: No conversion exists for ${objectType.constructor.name} ${geometry.lightStyle.name}`,
|
|
1251
|
-
type: 'no conversion',
|
|
1252
|
-
guid: _attributes.id
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
|
-
} );
|
|
1256
|
-
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
break;
|
|
1260
|
-
|
|
1261
|
-
case rhino.ObjectType.InstanceReference:
|
|
1262
|
-
|
|
1263
|
-
geometry = extractProperties( _geometry );
|
|
1264
|
-
geometry.xform = extractProperties( _geometry.xform );
|
|
1265
|
-
geometry.xform.array = _geometry.xform.toFloatArray( true );
|
|
1266
|
-
|
|
1267
|
-
break;
|
|
1268
|
-
|
|
1269
|
-
case rhino.ObjectType.SubD:
|
|
1270
|
-
|
|
1271
|
-
// TODO: precalculate resulting vertices and faces and warn on excessive results
|
|
1272
|
-
_geometry.subdivide( 3 );
|
|
1273
|
-
mesh = rhino.Mesh.createFromSubDControlNet( _geometry );
|
|
1274
|
-
if ( mesh ) {
|
|
1275
|
-
|
|
1276
|
-
geometry = mesh.toThreejsJSON();
|
|
1277
|
-
mesh.delete();
|
|
1278
|
-
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
break;
|
|
1282
|
-
|
|
1283
|
-
/*
|
|
1284
|
-
case rhino.ObjectType.Annotation:
|
|
1285
|
-
case rhino.ObjectType.Hatch:
|
|
1286
|
-
case rhino.ObjectType.ClipPlane:
|
|
1287
|
-
*/
|
|
1288
|
-
|
|
1289
|
-
default:
|
|
1290
|
-
|
|
1291
|
-
self.postMessage( { type: 'warning', id: taskID, data: {
|
|
1292
|
-
message: `THREE.3DMLoader: Conversion not implemented for ${objectType.constructor.name}`,
|
|
1293
|
-
type: 'not implemented',
|
|
1294
|
-
guid: _attributes.id
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
} );
|
|
1298
|
-
|
|
1299
|
-
break;
|
|
1300
|
-
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
if ( geometry ) {
|
|
1304
|
-
|
|
1305
|
-
attributes = extractProperties( _attributes );
|
|
1306
|
-
attributes.geometry = extractProperties( _geometry );
|
|
1307
|
-
|
|
1308
|
-
if ( _attributes.groupCount > 0 ) {
|
|
1309
|
-
|
|
1310
|
-
attributes.groupIds = _attributes.getGroupList();
|
|
1311
|
-
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
if ( _attributes.userStringCount > 0 ) {
|
|
1315
|
-
|
|
1316
|
-
attributes.userStrings = _attributes.getUserStrings();
|
|
1317
|
-
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
if ( _geometry.userStringCount > 0 ) {
|
|
1321
|
-
|
|
1322
|
-
attributes.geometry.userStrings = _geometry.getUserStrings();
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
attributes.drawColor = _attributes.drawColor( doc );
|
|
1327
|
-
|
|
1328
|
-
objectType = objectType.constructor.name;
|
|
1329
|
-
objectType = objectType.substring( 11, objectType.length );
|
|
1330
|
-
|
|
1331
|
-
return { geometry, attributes, objectType };
|
|
1332
|
-
|
|
1333
|
-
} else {
|
|
1334
|
-
|
|
1335
|
-
self.postMessage( { type: 'warning', id: taskID, data: {
|
|
1336
|
-
message: `THREE.3DMLoader: ${objectType.constructor.name} has no associated mesh geometry.`,
|
|
1337
|
-
type: 'missing mesh',
|
|
1338
|
-
guid: _attributes.id
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
|
-
} );
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
function extractProperties( object ) {
|
|
1348
|
-
|
|
1349
|
-
const result = {};
|
|
1350
|
-
|
|
1351
|
-
for ( const property in object ) {
|
|
1352
|
-
|
|
1353
|
-
const value = object[ property ];
|
|
1354
|
-
|
|
1355
|
-
if ( typeof value !== 'function' ) {
|
|
1356
|
-
|
|
1357
|
-
if ( typeof value === 'object' && value !== null && value.hasOwnProperty( 'constructor' ) ) {
|
|
1358
|
-
|
|
1359
|
-
result[ property ] = { name: value.constructor.name, value: value.value };
|
|
1360
|
-
|
|
1361
|
-
} else {
|
|
1362
|
-
|
|
1363
|
-
result[ property ] = value;
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
} else {
|
|
1368
|
-
|
|
1369
|
-
// these are functions that could be called to extract more data.
|
|
1370
|
-
//console.log( `${property}: ${object[ property ].constructor.name}` );
|
|
1371
|
-
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
return result;
|
|
1377
|
-
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
function curveToPoints( curve, pointLimit ) {
|
|
1381
|
-
|
|
1382
|
-
let pointCount = pointLimit;
|
|
1383
|
-
let rc = [];
|
|
1384
|
-
const ts = [];
|
|
1385
|
-
|
|
1386
|
-
if ( curve instanceof rhino.LineCurve ) {
|
|
1387
|
-
|
|
1388
|
-
return [ curve.pointAtStart, curve.pointAtEnd ];
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
if ( curve instanceof rhino.PolylineCurve ) {
|
|
1393
|
-
|
|
1394
|
-
pointCount = curve.pointCount;
|
|
1395
|
-
for ( let i = 0; i < pointCount; i ++ ) {
|
|
1396
|
-
|
|
1397
|
-
rc.push( curve.point( i ) );
|
|
1398
|
-
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
return rc;
|
|
1402
|
-
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
if ( curve instanceof rhino.PolyCurve ) {
|
|
1406
|
-
|
|
1407
|
-
const segmentCount = curve.segmentCount;
|
|
1408
|
-
|
|
1409
|
-
for ( let i = 0; i < segmentCount; i ++ ) {
|
|
1410
|
-
|
|
1411
|
-
const segment = curve.segmentCurve( i );
|
|
1412
|
-
const segmentArray = curveToPoints( segment, pointCount );
|
|
1413
|
-
rc = rc.concat( segmentArray );
|
|
1414
|
-
segment.delete();
|
|
1415
|
-
|
|
1416
|
-
}
|
|
1417
|
-
|
|
1418
|
-
return rc;
|
|
1419
|
-
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
if ( curve instanceof rhino.ArcCurve ) {
|
|
1423
|
-
|
|
1424
|
-
pointCount = Math.floor( curve.angleDegrees / 5 );
|
|
1425
|
-
pointCount = pointCount < 2 ? 2 : pointCount;
|
|
1426
|
-
// alternative to this hardcoded version: https://stackoverflow.com/a/18499923/2179399
|
|
1427
|
-
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
if ( curve instanceof rhino.NurbsCurve && curve.degree === 1 ) {
|
|
1431
|
-
|
|
1432
|
-
const pLine = curve.tryGetPolyline();
|
|
1433
|
-
|
|
1434
|
-
for ( let i = 0; i < pLine.count; i ++ ) {
|
|
1435
|
-
|
|
1436
|
-
rc.push( pLine.get( i ) );
|
|
1437
|
-
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
pLine.delete();
|
|
1441
|
-
|
|
1442
|
-
return rc;
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
const domain = curve.domain;
|
|
1447
|
-
const divisions = pointCount - 1.0;
|
|
1448
|
-
|
|
1449
|
-
for ( let j = 0; j < pointCount; j ++ ) {
|
|
1450
|
-
|
|
1451
|
-
const t = domain[ 0 ] + ( j / divisions ) * ( domain[ 1 ] - domain[ 0 ] );
|
|
1452
|
-
|
|
1453
|
-
if ( t === domain[ 0 ] || t === domain[ 1 ] ) {
|
|
1454
|
-
|
|
1455
|
-
ts.push( t );
|
|
1456
|
-
continue;
|
|
1457
|
-
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
const tan = curve.tangentAt( t );
|
|
1461
|
-
const prevTan = curve.tangentAt( ts.slice( - 1 )[ 0 ] );
|
|
1462
|
-
|
|
1463
|
-
// Duplicated from THREE.Vector3
|
|
1464
|
-
// How to pass imports to worker?
|
|
1465
|
-
|
|
1466
|
-
const tS = tan[ 0 ] * tan[ 0 ] + tan[ 1 ] * tan[ 1 ] + tan[ 2 ] * tan[ 2 ];
|
|
1467
|
-
const ptS = prevTan[ 0 ] * prevTan[ 0 ] + prevTan[ 1 ] * prevTan[ 1 ] + prevTan[ 2 ] * prevTan[ 2 ];
|
|
1468
|
-
|
|
1469
|
-
const denominator = Math.sqrt( tS * ptS );
|
|
1470
|
-
|
|
1471
|
-
let angle;
|
|
1472
|
-
|
|
1473
|
-
if ( denominator === 0 ) {
|
|
1474
|
-
|
|
1475
|
-
angle = Math.PI / 2;
|
|
1476
|
-
|
|
1477
|
-
} else {
|
|
1478
|
-
|
|
1479
|
-
const theta = ( tan.x * prevTan.x + tan.y * prevTan.y + tan.z * prevTan.z ) / denominator;
|
|
1480
|
-
angle = Math.acos( Math.max( - 1, Math.min( 1, theta ) ) );
|
|
1481
|
-
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
if ( angle < 0.1 ) continue;
|
|
1485
|
-
|
|
1486
|
-
ts.push( t );
|
|
1487
|
-
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
rc = ts.map( t => curve.pointAt( t ) );
|
|
1491
|
-
return rc;
|
|
1492
|
-
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
export { Rhino3dmLoader };
|