@anov/3d 0.0.1 → 0.0.2
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 +142 -1
- package/dist/core/camera.d.ts +31 -4
- package/dist/core/camera.js +62 -52
- package/dist/core/control/transformControls.d.ts +12 -0
- package/dist/core/control/transformControls.js +72 -0
- package/dist/core/cssRenderer.d.ts +17 -0
- package/dist/core/cssRenderer.js +36 -0
- package/dist/core/global/global.d.ts +27 -0
- package/dist/core/global/global.js +72 -0
- package/dist/core/global/globalControl.d.ts +17 -0
- package/dist/core/global/globalControl.js +62 -0
- package/dist/core/group.d.ts +51 -6
- package/dist/core/group.js +124 -16
- package/dist/core/line.d.ts +13 -0
- package/dist/core/line.js +83 -0
- package/dist/core/mesh.d.ts +12 -7
- package/dist/core/mesh.js +57 -56
- package/dist/core/model.d.ts +11 -3
- package/dist/core/model.js +34 -7
- package/dist/core/scene.d.ts +84 -25
- package/dist/core/scene.js +207 -53
- package/dist/core/use/useScene.d.ts +10 -0
- package/dist/core/use/useScene.js +14 -0
- package/dist/core/use/useframe.d.ts +6 -0
- package/dist/core/use/useframe.js +11 -0
- package/dist/export.d.ts +41 -0
- package/dist/export.js +37 -0
- package/dist/index.d.ts +3 -6
- package/dist/index.js +5 -6
- package/dist/threeCell.d.ts +8 -0
- package/dist/threeCell.js +16 -0
- package/dist/type.d.ts +4 -3
- package/dist/utils/createElement.d.ts +103 -0
- package/dist/utils/createElement.js +145 -0
- package/dist/utils/createLabel.d.ts +2 -0
- package/dist/utils/createLabel.js +4 -0
- package/dist/utils/index.d.ts +36 -0
- package/dist/utils/index.js +76 -0
- package/dist/utils/line.d.ts +0 -0
- package/dist/utils/line.js +0 -0
- package/dist/utils/move.d.ts +48 -0
- package/dist/utils/move.js +149 -0
- package/examples/fonts/LICENSE +13 -0
- package/examples/fonts/README.md +11 -0
- package/examples/fonts/droid/NOTICE +190 -0
- package/examples/fonts/droid/README.txt +18 -0
- package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
- package/examples/fonts/gentilis_bold.typeface.json +1 -0
- package/examples/fonts/gentilis_regular.typeface.json +1 -0
- package/examples/fonts/helvetiker_bold.typeface.json +1 -0
- package/examples/fonts/helvetiker_regular.typeface.json +1 -0
- package/examples/fonts/optimer_bold.typeface.json +1 -0
- package/examples/fonts/optimer_regular.typeface.json +1 -0
- package/examples/fonts/ttf/README.md +9 -0
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/animation/AnimationClipCreator.js +116 -0
- package/examples/jsm/animation/CCDIKSolver.js +482 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
- package/examples/jsm/animation/MMDPhysics.js +1406 -0
- package/examples/jsm/cameras/CinematicCamera.js +208 -0
- package/examples/jsm/capabilities/WebGL.js +91 -0
- package/examples/jsm/capabilities/WebGPU.js +53 -0
- package/examples/jsm/controls/ArcballControls.js +3224 -0
- package/examples/jsm/controls/DragControls.js +220 -0
- package/examples/jsm/controls/FirstPersonControls.js +325 -0
- package/examples/jsm/controls/FlyControls.js +300 -0
- package/examples/jsm/controls/MapControls.js +28 -0
- package/examples/jsm/controls/OrbitControls.js +1388 -0
- package/examples/jsm/controls/PointerLockControls.js +162 -0
- package/examples/jsm/controls/TrackballControls.js +828 -0
- package/examples/jsm/controls/TransformControls.js +1557 -0
- package/examples/jsm/csm/CSM.js +384 -0
- package/examples/jsm/csm/CSMFrustum.js +152 -0
- package/examples/jsm/csm/CSMHelper.js +193 -0
- package/examples/jsm/csm/CSMShader.js +252 -0
- package/examples/jsm/curves/CurveExtras.js +422 -0
- package/examples/jsm/curves/NURBSCurve.js +80 -0
- package/examples/jsm/curves/NURBSSurface.js +52 -0
- package/examples/jsm/curves/NURBSUtils.js +487 -0
- package/examples/jsm/effects/AnaglyphEffect.js +154 -0
- package/examples/jsm/effects/AsciiEffect.js +263 -0
- package/examples/jsm/effects/OutlineEffect.js +539 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.js +119 -0
- package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
- package/examples/jsm/effects/StereoEffect.js +55 -0
- package/examples/jsm/environments/DebugEnvironment.js +52 -0
- package/examples/jsm/environments/RoomEnvironment.js +148 -0
- package/examples/jsm/exporters/DRACOExporter.js +267 -0
- package/examples/jsm/exporters/EXRExporter.js +501 -0
- package/examples/jsm/exporters/GLTFExporter.js +3161 -0
- package/examples/jsm/exporters/KTX2Exporter.js +292 -0
- package/examples/jsm/exporters/MMDExporter.js +217 -0
- package/examples/jsm/exporters/OBJExporter.js +284 -0
- package/examples/jsm/exporters/PLYExporter.js +528 -0
- package/examples/jsm/exporters/STLExporter.js +199 -0
- package/examples/jsm/exporters/USDZExporter.js +711 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
- package/examples/jsm/geometries/ConvexGeometry.js +53 -0
- package/examples/jsm/geometries/DecalGeometry.js +356 -0
- package/examples/jsm/geometries/ParametricGeometries.js +254 -0
- package/examples/jsm/geometries/ParametricGeometry.js +139 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
- package/examples/jsm/geometries/TeapotGeometry.js +704 -0
- package/examples/jsm/geometries/TextGeometry.js +57 -0
- package/examples/jsm/helpers/LightProbeHelper.js +130 -0
- package/examples/jsm/helpers/OctreeHelper.js +73 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
- package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
- package/examples/jsm/helpers/ViewHelper.js +333 -0
- package/examples/jsm/interactive/HTMLMesh.js +565 -0
- package/examples/jsm/interactive/InteractiveGroup.js +116 -0
- package/examples/jsm/interactive/SelectionBox.js +227 -0
- package/examples/jsm/interactive/SelectionHelper.js +104 -0
- package/examples/jsm/libs/ammo.wasm.js +822 -0
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/basis/README.md +46 -0
- package/examples/jsm/libs/basis/basis_transcoder.js +21 -0
- package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/jsm/libs/chevrotain.module.min.js +141 -0
- package/examples/jsm/libs/draco/README.md +32 -0
- package/examples/jsm/libs/draco/draco_decoder.js +34 -0
- package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +33 -0
- package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
- package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/examples/jsm/libs/ecsy.module.js +1792 -0
- package/examples/jsm/libs/fflate.module.js +2474 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
- package/examples/jsm/libs/mikktspace.module.js +128 -0
- package/examples/jsm/libs/mmdparser.module.js +11530 -0
- package/examples/jsm/libs/motion-controllers.module.js +397 -0
- package/examples/jsm/libs/opentype.module.js +14568 -0
- package/examples/jsm/libs/potpack.module.js +125 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +167 -0
- package/examples/jsm/libs/tween.module.js +803 -0
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/lights/IESSpotLight.js +25 -0
- package/examples/jsm/lights/LightProbeGenerator.js +252 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
- package/examples/jsm/lines/Line2.js +19 -0
- package/examples/jsm/lines/LineGeometry.js +79 -0
- package/examples/jsm/lines/LineMaterial.js +702 -0
- package/examples/jsm/lines/LineSegments2.js +361 -0
- package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
- package/examples/jsm/lines/Wireframe.js +56 -0
- package/examples/jsm/lines/WireframeGeometry2.js +24 -0
- package/examples/jsm/loaders/3DMLoader.js +1497 -0
- package/examples/jsm/loaders/3MFLoader.js +1478 -0
- package/examples/jsm/loaders/AMFLoader.js +521 -0
- package/examples/jsm/loaders/BVHLoader.js +437 -0
- package/examples/jsm/loaders/ColladaLoader.js +4122 -0
- package/examples/jsm/loaders/DDSLoader.js +274 -0
- package/examples/jsm/loaders/DRACOLoader.js +612 -0
- package/examples/jsm/loaders/EXRLoader.js +2309 -0
- package/examples/jsm/loaders/FBXLoader.js +4142 -0
- package/examples/jsm/loaders/FontLoader.js +183 -0
- package/examples/jsm/loaders/GCodeLoader.js +261 -0
- package/examples/jsm/loaders/GLTFLoader.js +4576 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
- package/examples/jsm/loaders/IESLoader.js +337 -0
- package/examples/jsm/loaders/KMZLoader.js +130 -0
- package/examples/jsm/loaders/KTX2Loader.js +868 -0
- package/examples/jsm/loaders/KTXLoader.js +176 -0
- package/examples/jsm/loaders/LDrawLoader.js +2464 -0
- package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
- package/examples/jsm/loaders/LWOLoader.js +1052 -0
- package/examples/jsm/loaders/LogLuvLoader.js +606 -0
- package/examples/jsm/loaders/LottieLoader.js +77 -0
- package/examples/jsm/loaders/MD2Loader.js +399 -0
- package/examples/jsm/loaders/MDDLoader.js +102 -0
- package/examples/jsm/loaders/MMDLoader.js +2273 -0
- package/examples/jsm/loaders/MTLLoader.js +567 -0
- package/examples/jsm/loaders/MaterialXLoader.js +734 -0
- package/examples/jsm/loaders/NRRDLoader.js +699 -0
- package/examples/jsm/loaders/OBJLoader.js +905 -0
- package/examples/jsm/loaders/PCDLoader.js +467 -0
- package/examples/jsm/loaders/PDBLoader.js +232 -0
- package/examples/jsm/loaders/PLYLoader.js +771 -0
- package/examples/jsm/loaders/PVRLoader.js +251 -0
- package/examples/jsm/loaders/RGBELoader.js +468 -0
- package/examples/jsm/loaders/RGBMLoader.js +1065 -0
- package/examples/jsm/loaders/STLLoader.js +403 -0
- package/examples/jsm/loaders/SVGLoader.js +3172 -0
- package/examples/jsm/loaders/TDSLoader.js +1124 -0
- package/examples/jsm/loaders/TGALoader.js +517 -0
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/TTFLoader.js +214 -0
- package/examples/jsm/loaders/TiltLoader.js +520 -0
- package/examples/jsm/loaders/USDZLoader.js +633 -0
- package/examples/jsm/loaders/VOXLoader.js +311 -0
- package/examples/jsm/loaders/VRMLLoader.js +3533 -0
- package/examples/jsm/loaders/VTKLoader.js +1163 -0
- package/examples/jsm/loaders/XYZLoader.js +106 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
- package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +420 -0
- package/examples/jsm/math/Capsule.js +137 -0
- package/examples/jsm/math/ColorConverter.js +36 -0
- package/examples/jsm/math/ConvexHull.js +1271 -0
- package/examples/jsm/math/ImprovedNoise.js +71 -0
- package/examples/jsm/math/Lut.js +204 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +250 -0
- package/examples/jsm/math/OBB.js +423 -0
- package/examples/jsm/math/Octree.js +462 -0
- package/examples/jsm/math/SimplexNoise.js +444 -0
- package/examples/jsm/misc/ConvexObjectBreaker.js +519 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +446 -0
- package/examples/jsm/misc/Gyroscope.js +66 -0
- package/examples/jsm/misc/MD2Character.js +276 -0
- package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
- package/examples/jsm/misc/MorphAnimMesh.js +75 -0
- package/examples/jsm/misc/MorphBlendMesh.js +322 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +323 -0
- package/examples/jsm/misc/RollerCoaster.js +566 -0
- package/examples/jsm/misc/TubePainter.js +205 -0
- package/examples/jsm/misc/Volume.js +473 -0
- package/examples/jsm/misc/VolumeSlice.js +229 -0
- package/examples/jsm/modifiers/CurveModifier.js +326 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
- package/examples/jsm/modifiers/TessellateModifier.js +307 -0
- package/examples/jsm/nodes/Nodes.js +171 -0
- package/examples/jsm/nodes/accessors/BitangentNode.js +89 -0
- package/examples/jsm/nodes/accessors/BufferAttributeNode.js +99 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +30 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +98 -0
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +103 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +77 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +71 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +267 -0
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +39 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +34 -0
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +29 -0
- package/examples/jsm/nodes/accessors/MorphNode.js +70 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +96 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +150 -0
- package/examples/jsm/nodes/accessors/PointUVNode.js +26 -0
- package/examples/jsm/nodes/accessors/PositionNode.js +104 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +72 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +35 -0
- package/examples/jsm/nodes/accessors/SceneNode.js +52 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +93 -0
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +27 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +103 -0
- package/examples/jsm/nodes/accessors/TextureBicubicNode.js +94 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +271 -0
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +35 -0
- package/examples/jsm/nodes/accessors/UVNode.js +47 -0
- package/examples/jsm/nodes/accessors/UserDataNode.js +29 -0
- package/examples/jsm/nodes/code/CodeNode.js +78 -0
- package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
- package/examples/jsm/nodes/code/FunctionCallNode.js +96 -0
- package/examples/jsm/nodes/code/FunctionNode.js +127 -0
- package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
- package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +26 -0
- package/examples/jsm/nodes/core/AttributeNode.js +102 -0
- package/examples/jsm/nodes/core/BypassNode.js +45 -0
- package/examples/jsm/nodes/core/CacheNode.js +46 -0
- package/examples/jsm/nodes/core/ConstNode.js +32 -0
- package/examples/jsm/nodes/core/ContextNode.js +61 -0
- package/examples/jsm/nodes/core/IndexNode.js +66 -0
- package/examples/jsm/nodes/core/InputNode.js +83 -0
- package/examples/jsm/nodes/core/LightingModel.js +15 -0
- package/examples/jsm/nodes/core/Node.js +454 -0
- package/examples/jsm/nodes/core/NodeAttribute.js +15 -0
- package/examples/jsm/nodes/core/NodeBuilder.js +1016 -0
- package/examples/jsm/nodes/core/NodeCache.js +26 -0
- package/examples/jsm/nodes/core/NodeCode.js +15 -0
- package/examples/jsm/nodes/core/NodeFrame.js +110 -0
- package/examples/jsm/nodes/core/NodeFunction.js +22 -0
- package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
- package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
- package/examples/jsm/nodes/core/NodeParser.js +11 -0
- package/examples/jsm/nodes/core/NodeUniform.js +28 -0
- package/examples/jsm/nodes/core/NodeUtils.js +212 -0
- package/examples/jsm/nodes/core/NodeVar.js +14 -0
- package/examples/jsm/nodes/core/NodeVarying.js +17 -0
- package/examples/jsm/nodes/core/PropertyNode.js +61 -0
- package/examples/jsm/nodes/core/StackNode.js +99 -0
- package/examples/jsm/nodes/core/TempNode.js +58 -0
- package/examples/jsm/nodes/core/UniformNode.js +61 -0
- package/examples/jsm/nodes/core/VarNode.js +87 -0
- package/examples/jsm/nodes/core/VaryingNode.js +69 -0
- package/examples/jsm/nodes/core/constants.js +27 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +99 -0
- package/examples/jsm/nodes/display/BumpMapNode.js +77 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +100 -0
- package/examples/jsm/nodes/display/ColorSpaceNode.js +108 -0
- package/examples/jsm/nodes/display/FrontFacingNode.js +27 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +106 -0
- package/examples/jsm/nodes/display/PosterizeNode.js +32 -0
- package/examples/jsm/nodes/display/ToneMappingNode.js +141 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +69 -0
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +34 -0
- package/examples/jsm/nodes/display/ViewportNode.js +115 -0
- package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +31 -0
- package/examples/jsm/nodes/display/ViewportTextureNode.js +75 -0
- package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
- package/examples/jsm/nodes/fog/FogNode.js +37 -0
- package/examples/jsm/nodes/fog/FogRangeNode.js +34 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +40 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +43 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +29 -0
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
- package/examples/jsm/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +16 -0
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +13 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +20 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +67 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +343 -0
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +13 -0
- package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +104 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +85 -0
- package/examples/jsm/nodes/lighting/AONode.js +27 -0
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +184 -0
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +40 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +191 -0
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +55 -0
- package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
- package/examples/jsm/nodes/lighting/LightNode.js +57 -0
- package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +102 -0
- package/examples/jsm/nodes/lighting/LightingNode.js +21 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +128 -0
- package/examples/jsm/nodes/lighting/PointLightNode.js +68 -0
- package/examples/jsm/nodes/lighting/SpotLightNode.js +89 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +108 -0
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +59 -0
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +28 -0
- package/examples/jsm/nodes/materials/Materials.js +12 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +27 -0
- package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +40 -0
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +65 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +128 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +80 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +536 -0
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +49 -0
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +103 -0
- package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +68 -0
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +618 -0
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +19 -0
- package/examples/jsm/nodes/math/CondNode.js +86 -0
- package/examples/jsm/nodes/math/MathNode.js +359 -0
- package/examples/jsm/nodes/math/OperatorNode.js +269 -0
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
- package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
- package/examples/jsm/nodes/procedural/CheckerNode.js +42 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +420 -0
- package/examples/jsm/nodes/utils/ArrayElementNode.js +33 -0
- package/examples/jsm/nodes/utils/ConvertNode.js +65 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +33 -0
- package/examples/jsm/nodes/utils/JoinNode.js +51 -0
- package/examples/jsm/nodes/utils/LoopNode.js +186 -0
- package/examples/jsm/nodes/utils/MatcapUVNode.js +30 -0
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +46 -0
- package/examples/jsm/nodes/utils/OscNode.js +81 -0
- package/examples/jsm/nodes/utils/PackingNode.js +55 -0
- package/examples/jsm/nodes/utils/RemapNode.js +42 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +43 -0
- package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
- package/examples/jsm/nodes/utils/SplitNode.js +104 -0
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +41 -0
- package/examples/jsm/nodes/utils/TimerNode.js +94 -0
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +62 -0
- package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
- package/examples/jsm/objects/Lensflare.js +377 -0
- package/examples/jsm/objects/MarchingCubes.js +1176 -0
- package/examples/jsm/objects/Reflector.js +264 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
- package/examples/jsm/objects/Refractor.js +324 -0
- package/examples/jsm/objects/ShadowMesh.js +80 -0
- package/examples/jsm/objects/Sky.js +219 -0
- package/examples/jsm/objects/Water.js +330 -0
- package/examples/jsm/objects/Water2.js +358 -0
- package/examples/jsm/offscreen/jank.js +45 -0
- package/examples/jsm/offscreen/offscreen.js +8 -0
- package/examples/jsm/offscreen/scene.js +86 -0
- package/examples/jsm/physics/AmmoPhysics.js +285 -0
- package/examples/jsm/physics/RapierPhysics.js +199 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +104 -0
- package/examples/jsm/postprocessing/BloomPass.js +172 -0
- package/examples/jsm/postprocessing/BokehPass.js +140 -0
- package/examples/jsm/postprocessing/ClearPass.js +46 -0
- package/examples/jsm/postprocessing/CubeTexturePass.js +85 -0
- package/examples/jsm/postprocessing/DotScreenPass.js +65 -0
- package/examples/jsm/postprocessing/EffectComposer.js +231 -0
- package/examples/jsm/postprocessing/FilmPass.js +66 -0
- package/examples/jsm/postprocessing/GlitchPass.js +128 -0
- package/examples/jsm/postprocessing/HalftonePass.js +79 -0
- package/examples/jsm/postprocessing/LUTPass.js +173 -0
- package/examples/jsm/postprocessing/MaskPass.js +104 -0
- package/examples/jsm/postprocessing/OutlinePass.js +654 -0
- package/examples/jsm/postprocessing/OutputPass.js +91 -0
- package/examples/jsm/postprocessing/Pass.js +84 -0
- package/examples/jsm/postprocessing/RenderPass.js +81 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +235 -0
- package/examples/jsm/postprocessing/SAOPass.js +411 -0
- package/examples/jsm/postprocessing/SMAAPass.js +201 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +228 -0
- package/examples/jsm/postprocessing/SSAOPass.js +440 -0
- package/examples/jsm/postprocessing/SSRPass.js +641 -0
- package/examples/jsm/postprocessing/SavePass.js +79 -0
- package/examples/jsm/postprocessing/ShaderPass.js +77 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +189 -0
- package/examples/jsm/postprocessing/TexturePass.js +67 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +415 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +215 -0
- package/examples/jsm/renderers/CSS3DRenderer.js +335 -0
- package/examples/jsm/renderers/Projector.js +918 -0
- package/examples/jsm/renderers/SVGRenderer.js +553 -0
- package/examples/jsm/renderers/common/Animation.js +58 -0
- package/examples/jsm/renderers/common/Attributes.js +75 -0
- package/examples/jsm/renderers/common/Backend.js +162 -0
- package/examples/jsm/renderers/common/Background.js +136 -0
- package/examples/jsm/renderers/common/Binding.js +19 -0
- package/examples/jsm/renderers/common/Bindings.js +165 -0
- package/examples/jsm/renderers/common/Buffer.js +38 -0
- package/examples/jsm/renderers/common/BufferUtils.js +33 -0
- package/examples/jsm/renderers/common/ChainMap.js +89 -0
- package/examples/jsm/renderers/common/ComputePipeline.js +17 -0
- package/examples/jsm/renderers/common/Constants.js +14 -0
- package/examples/jsm/renderers/common/CubeRenderTarget.js +65 -0
- package/examples/jsm/renderers/common/DataMap.js +54 -0
- package/examples/jsm/renderers/common/Geometries.js +215 -0
- package/examples/jsm/renderers/common/Info.js +73 -0
- package/examples/jsm/renderers/common/Pipeline.js +13 -0
- package/examples/jsm/renderers/common/Pipelines.js +370 -0
- package/examples/jsm/renderers/common/ProgrammableStage.js +18 -0
- package/examples/jsm/renderers/common/RenderContext.js +38 -0
- package/examples/jsm/renderers/common/RenderContexts.js +49 -0
- package/examples/jsm/renderers/common/RenderList.js +178 -0
- package/examples/jsm/renderers/common/RenderLists.js +38 -0
- package/examples/jsm/renderers/common/RenderObject.js +129 -0
- package/examples/jsm/renderers/common/RenderObjects.js +95 -0
- package/examples/jsm/renderers/common/RenderPipeline.js +16 -0
- package/examples/jsm/renderers/common/Renderer.js +895 -0
- package/examples/jsm/renderers/common/SampledTexture.js +80 -0
- package/examples/jsm/renderers/common/Sampler.js +18 -0
- package/examples/jsm/renderers/common/StorageBuffer.js +17 -0
- package/examples/jsm/renderers/common/Textures.js +218 -0
- package/examples/jsm/renderers/common/Uniform.js +140 -0
- package/examples/jsm/renderers/common/UniformBuffer.js +15 -0
- package/examples/jsm/renderers/common/UniformsGroup.js +299 -0
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +39 -0
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +21 -0
- package/examples/jsm/renderers/common/nodes/NodeUniform.js +135 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +330 -0
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +340 -0
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +764 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +844 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +32 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +902 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +104 -0
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeParser.js +14 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +274 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +223 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +324 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +533 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +163 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +964 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +92 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
- package/examples/jsm/shaders/AfterimageShader.js +56 -0
- package/examples/jsm/shaders/BasicShader.js +27 -0
- package/examples/jsm/shaders/BleachBypassShader.js +62 -0
- package/examples/jsm/shaders/BlendShader.js +47 -0
- package/examples/jsm/shaders/BokehShader.js +143 -0
- package/examples/jsm/shaders/BokehShader2.js +393 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
- package/examples/jsm/shaders/ColorifyShader.js +51 -0
- package/examples/jsm/shaders/ConvolutionShader.js +103 -0
- package/examples/jsm/shaders/CopyShader.js +45 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
- package/examples/jsm/shaders/DigitalGlitch.js +101 -0
- package/examples/jsm/shaders/DotScreenShader.js +70 -0
- package/examples/jsm/shaders/ExposureShader.js +44 -0
- package/examples/jsm/shaders/FXAAShader.js +286 -0
- package/examples/jsm/shaders/FilmShader.js +102 -0
- package/examples/jsm/shaders/FocusShader.js +87 -0
- package/examples/jsm/shaders/FreiChenShader.js +94 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +43 -0
- package/examples/jsm/shaders/GodRaysShader.js +313 -0
- package/examples/jsm/shaders/HalftoneShader.js +310 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +59 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
- package/examples/jsm/shaders/HueSaturationShader.js +65 -0
- package/examples/jsm/shaders/KaleidoShader.js +56 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
- package/examples/jsm/shaders/LuminosityShader.js +46 -0
- package/examples/jsm/shaders/MMDToonShader.js +132 -0
- package/examples/jsm/shaders/MirrorShader.js +54 -0
- package/examples/jsm/shaders/NormalMapShader.js +53 -0
- package/examples/jsm/shaders/OutputShader.js +78 -0
- package/examples/jsm/shaders/RGBShiftShader.js +54 -0
- package/examples/jsm/shaders/SAOShader.js +188 -0
- package/examples/jsm/shaders/SMAAShader.js +460 -0
- package/examples/jsm/shaders/SSAOShader.js +288 -0
- package/examples/jsm/shaders/SSRShader.js +364 -0
- package/examples/jsm/shaders/SepiaShader.js +52 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
- package/examples/jsm/shaders/TechnicolorShader.js +43 -0
- package/examples/jsm/shaders/ToonShader.js +326 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/shaders/VerticalBlurShader.js +59 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
- package/examples/jsm/shaders/VignetteShader.js +51 -0
- package/examples/jsm/shaders/VolumeShader.js +289 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +93 -0
- package/examples/jsm/textures/FlakesTexture.js +40 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +1373 -0
- package/examples/jsm/utils/CameraUtils.js +73 -0
- package/examples/jsm/utils/GPUStatsPanel.js +128 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
- package/examples/jsm/utils/GeometryUtils.js +221 -0
- package/examples/jsm/utils/LDrawUtils.js +202 -0
- package/examples/jsm/utils/PackedPhongMaterial.js +178 -0
- package/examples/jsm/utils/SceneUtils.js +254 -0
- package/examples/jsm/utils/ShadowMapViewer.js +210 -0
- package/examples/jsm/utils/SkeletonUtils.js +413 -0
- package/examples/jsm/utils/TextureUtils.js +86 -0
- package/examples/jsm/utils/UVsDebug.js +165 -0
- package/examples/jsm/utils/WorkerPool.js +102 -0
- package/examples/jsm/webxr/ARButton.js +208 -0
- package/examples/jsm/webxr/OculusHandModel.js +109 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +413 -0
- package/examples/jsm/webxr/Text2D.js +38 -0
- package/examples/jsm/webxr/VRButton.js +200 -0
- package/examples/jsm/webxr/XRButton.js +198 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +299 -0
- package/examples/jsm/webxr/XREstimatedLight.js +223 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +112 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
- package/examples/jsm/webxr/XRPlanes.js +100 -0
- package/lib/3d.min.js +1 -0
- package/package.json +25 -12
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import * as fflate from '../libs/fflate.module.js';
|
|
3
|
+
|
|
4
|
+
class USDZExporter {
|
|
5
|
+
|
|
6
|
+
async parse( scene, options = {} ) {
|
|
7
|
+
|
|
8
|
+
options = Object.assign( {
|
|
9
|
+
ar: {
|
|
10
|
+
anchoring: { type: 'plane' },
|
|
11
|
+
planeAnchoring: { alignment: 'horizontal' }
|
|
12
|
+
},
|
|
13
|
+
quickLookCompatible: false,
|
|
14
|
+
}, options );
|
|
15
|
+
|
|
16
|
+
const files = {};
|
|
17
|
+
const modelFileName = 'model.usda';
|
|
18
|
+
|
|
19
|
+
// model file should be first in USDZ archive so we init it here
|
|
20
|
+
files[ modelFileName ] = null;
|
|
21
|
+
|
|
22
|
+
let output = buildHeader();
|
|
23
|
+
|
|
24
|
+
output += buildSceneStart( options );
|
|
25
|
+
|
|
26
|
+
const materials = {};
|
|
27
|
+
const textures = {};
|
|
28
|
+
|
|
29
|
+
scene.traverseVisible( ( object ) => {
|
|
30
|
+
|
|
31
|
+
if ( object.isMesh ) {
|
|
32
|
+
|
|
33
|
+
const geometry = object.geometry;
|
|
34
|
+
const material = object.material;
|
|
35
|
+
|
|
36
|
+
if ( material.isMeshStandardMaterial ) {
|
|
37
|
+
|
|
38
|
+
const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usda';
|
|
39
|
+
|
|
40
|
+
if ( ! ( geometryFileName in files ) ) {
|
|
41
|
+
|
|
42
|
+
const meshObject = buildMeshObject( geometry );
|
|
43
|
+
files[ geometryFileName ] = buildUSDFileAsString( meshObject );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if ( ! ( material.uuid in materials ) ) {
|
|
48
|
+
|
|
49
|
+
materials[ material.uuid ] = material;
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
output += buildXform( object, geometry, material );
|
|
54
|
+
|
|
55
|
+
} else {
|
|
56
|
+
|
|
57
|
+
console.warn( 'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)', object );
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
} else if ( object.isCamera ) {
|
|
62
|
+
|
|
63
|
+
output += buildCamera( object );
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
output += buildSceneEnd();
|
|
71
|
+
|
|
72
|
+
output += buildMaterials( materials, textures, options.quickLookCompatible );
|
|
73
|
+
|
|
74
|
+
files[ modelFileName ] = fflate.strToU8( output );
|
|
75
|
+
output = null;
|
|
76
|
+
|
|
77
|
+
for ( const id in textures ) {
|
|
78
|
+
|
|
79
|
+
const texture = textures[ id ];
|
|
80
|
+
|
|
81
|
+
const canvas = imageToCanvas( texture.image, texture.flipY );
|
|
82
|
+
const blob = await new Promise( resolve => canvas.toBlob( resolve, 'image/png', 1 ) );
|
|
83
|
+
|
|
84
|
+
files[ `textures/Texture_${ id }.png` ] = new Uint8Array( await blob.arrayBuffer() );
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 64 byte alignment
|
|
89
|
+
// https://github.com/101arrowz/fflate/issues/39#issuecomment-777263109
|
|
90
|
+
|
|
91
|
+
let offset = 0;
|
|
92
|
+
|
|
93
|
+
for ( const filename in files ) {
|
|
94
|
+
|
|
95
|
+
const file = files[ filename ];
|
|
96
|
+
const headerSize = 34 + filename.length;
|
|
97
|
+
|
|
98
|
+
offset += headerSize;
|
|
99
|
+
|
|
100
|
+
const offsetMod64 = offset & 63;
|
|
101
|
+
|
|
102
|
+
if ( offsetMod64 !== 4 ) {
|
|
103
|
+
|
|
104
|
+
const padLength = 64 - offsetMod64;
|
|
105
|
+
const padding = new Uint8Array( padLength );
|
|
106
|
+
|
|
107
|
+
files[ filename ] = [ file, { extra: { 12345: padding } } ];
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
offset = file.length;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return fflate.zipSync( files, { level: 0 } );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function imageToCanvas( image, flipY ) {
|
|
122
|
+
|
|
123
|
+
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
124
|
+
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
125
|
+
( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
|
|
126
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
127
|
+
|
|
128
|
+
const scale = 1024 / Math.max( image.width, image.height );
|
|
129
|
+
|
|
130
|
+
const canvas = document.createElement( 'canvas' );
|
|
131
|
+
canvas.width = image.width * Math.min( 1, scale );
|
|
132
|
+
canvas.height = image.height * Math.min( 1, scale );
|
|
133
|
+
|
|
134
|
+
const context = canvas.getContext( '2d' );
|
|
135
|
+
|
|
136
|
+
// TODO: We should be able to do this in the UsdTransform2d?
|
|
137
|
+
|
|
138
|
+
if ( flipY === true ) {
|
|
139
|
+
|
|
140
|
+
context.translate( 0, canvas.height );
|
|
141
|
+
context.scale( 1, - 1 );
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
context.drawImage( image, 0, 0, canvas.width, canvas.height );
|
|
146
|
+
|
|
147
|
+
return canvas;
|
|
148
|
+
|
|
149
|
+
} else {
|
|
150
|
+
|
|
151
|
+
throw new Error( 'THREE.USDZExporter: No valid image data found. Unable to process texture.' );
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//
|
|
158
|
+
|
|
159
|
+
const PRECISION = 7;
|
|
160
|
+
|
|
161
|
+
function buildHeader() {
|
|
162
|
+
|
|
163
|
+
return `#usda 1.0
|
|
164
|
+
(
|
|
165
|
+
customLayerData = {
|
|
166
|
+
string creator = "Three.js USDZExporter"
|
|
167
|
+
}
|
|
168
|
+
defaultPrim = "Root"
|
|
169
|
+
metersPerUnit = 1
|
|
170
|
+
upAxis = "Y"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function buildSceneStart( options ) {
|
|
178
|
+
|
|
179
|
+
return `def Xform "Root"
|
|
180
|
+
{
|
|
181
|
+
def Scope "Scenes" (
|
|
182
|
+
kind = "sceneLibrary"
|
|
183
|
+
)
|
|
184
|
+
{
|
|
185
|
+
def Xform "Scene" (
|
|
186
|
+
customData = {
|
|
187
|
+
bool preliminary_collidesWithEnvironment = 0
|
|
188
|
+
string sceneName = "Scene"
|
|
189
|
+
}
|
|
190
|
+
sceneName = "Scene"
|
|
191
|
+
)
|
|
192
|
+
{
|
|
193
|
+
token preliminary:anchoring:type = "${options.ar.anchoring.type}"
|
|
194
|
+
token preliminary:planeAnchoring:alignment = "${options.ar.planeAnchoring.alignment}"
|
|
195
|
+
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function buildSceneEnd() {
|
|
201
|
+
|
|
202
|
+
return `
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
`;
|
|
208
|
+
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function buildUSDFileAsString( dataToInsert ) {
|
|
212
|
+
|
|
213
|
+
let output = buildHeader();
|
|
214
|
+
output += dataToInsert;
|
|
215
|
+
return fflate.strToU8( output );
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Xform
|
|
220
|
+
|
|
221
|
+
function buildXform( object, geometry, material ) {
|
|
222
|
+
|
|
223
|
+
const name = 'Object_' + object.id;
|
|
224
|
+
const transform = buildMatrix( object.matrixWorld );
|
|
225
|
+
|
|
226
|
+
if ( object.matrixWorld.determinant() < 0 ) {
|
|
227
|
+
|
|
228
|
+
console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', object );
|
|
229
|
+
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return `def Xform "${ name }" (
|
|
233
|
+
prepend references = @./geometries/Geometry_${ geometry.id }.usda@</Geometry>
|
|
234
|
+
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
235
|
+
)
|
|
236
|
+
{
|
|
237
|
+
matrix4d xformOp:transform = ${ transform }
|
|
238
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
239
|
+
|
|
240
|
+
rel material:binding = </Materials/Material_${ material.id }>
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
`;
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function buildMatrix( matrix ) {
|
|
248
|
+
|
|
249
|
+
const array = matrix.elements;
|
|
250
|
+
|
|
251
|
+
return `( ${ buildMatrixRow( array, 0 ) }, ${ buildMatrixRow( array, 4 ) }, ${ buildMatrixRow( array, 8 ) }, ${ buildMatrixRow( array, 12 ) } )`;
|
|
252
|
+
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function buildMatrixRow( array, offset ) {
|
|
256
|
+
|
|
257
|
+
return `(${ array[ offset + 0 ] }, ${ array[ offset + 1 ] }, ${ array[ offset + 2 ] }, ${ array[ offset + 3 ] })`;
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Mesh
|
|
262
|
+
|
|
263
|
+
function buildMeshObject( geometry ) {
|
|
264
|
+
|
|
265
|
+
const mesh = buildMesh( geometry );
|
|
266
|
+
return `
|
|
267
|
+
def "Geometry"
|
|
268
|
+
{
|
|
269
|
+
${mesh}
|
|
270
|
+
}
|
|
271
|
+
`;
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function buildMesh( geometry ) {
|
|
276
|
+
|
|
277
|
+
const name = 'Geometry';
|
|
278
|
+
const attributes = geometry.attributes;
|
|
279
|
+
const count = attributes.position.count;
|
|
280
|
+
|
|
281
|
+
return `
|
|
282
|
+
def Mesh "${ name }"
|
|
283
|
+
{
|
|
284
|
+
int[] faceVertexCounts = [${ buildMeshVertexCount( geometry ) }]
|
|
285
|
+
int[] faceVertexIndices = [${ buildMeshVertexIndices( geometry ) }]
|
|
286
|
+
normal3f[] normals = [${ buildVector3Array( attributes.normal, count )}] (
|
|
287
|
+
interpolation = "vertex"
|
|
288
|
+
)
|
|
289
|
+
point3f[] points = [${ buildVector3Array( attributes.position, count )}]
|
|
290
|
+
${ buildPrimvars( attributes, count ) }
|
|
291
|
+
uniform token subdivisionScheme = "none"
|
|
292
|
+
}
|
|
293
|
+
`;
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function buildMeshVertexCount( geometry ) {
|
|
298
|
+
|
|
299
|
+
const count = geometry.index !== null ? geometry.index.count : geometry.attributes.position.count;
|
|
300
|
+
|
|
301
|
+
return Array( count / 3 ).fill( 3 ).join( ', ' );
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function buildMeshVertexIndices( geometry ) {
|
|
306
|
+
|
|
307
|
+
const index = geometry.index;
|
|
308
|
+
const array = [];
|
|
309
|
+
|
|
310
|
+
if ( index !== null ) {
|
|
311
|
+
|
|
312
|
+
for ( let i = 0; i < index.count; i ++ ) {
|
|
313
|
+
|
|
314
|
+
array.push( index.getX( i ) );
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
} else {
|
|
319
|
+
|
|
320
|
+
const length = geometry.attributes.position.count;
|
|
321
|
+
|
|
322
|
+
for ( let i = 0; i < length; i ++ ) {
|
|
323
|
+
|
|
324
|
+
array.push( i );
|
|
325
|
+
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return array.join( ', ' );
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function buildVector3Array( attribute, count ) {
|
|
335
|
+
|
|
336
|
+
if ( attribute === undefined ) {
|
|
337
|
+
|
|
338
|
+
console.warn( 'USDZExporter: Normals missing.' );
|
|
339
|
+
return Array( count ).fill( '(0, 0, 0)' ).join( ', ' );
|
|
340
|
+
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const array = [];
|
|
344
|
+
|
|
345
|
+
for ( let i = 0; i < attribute.count; i ++ ) {
|
|
346
|
+
|
|
347
|
+
const x = attribute.getX( i );
|
|
348
|
+
const y = attribute.getY( i );
|
|
349
|
+
const z = attribute.getZ( i );
|
|
350
|
+
|
|
351
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ y.toPrecision( PRECISION ) }, ${ z.toPrecision( PRECISION ) })` );
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return array.join( ', ' );
|
|
356
|
+
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function buildVector2Array( attribute, count ) {
|
|
360
|
+
|
|
361
|
+
if ( attribute === undefined ) {
|
|
362
|
+
|
|
363
|
+
console.warn( 'USDZExporter: UVs missing.' );
|
|
364
|
+
return Array( count ).fill( '(0, 0)' ).join( ', ' );
|
|
365
|
+
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const array = [];
|
|
369
|
+
|
|
370
|
+
for ( let i = 0; i < attribute.count; i ++ ) {
|
|
371
|
+
|
|
372
|
+
const x = attribute.getX( i );
|
|
373
|
+
const y = attribute.getY( i );
|
|
374
|
+
|
|
375
|
+
array.push( `(${ x.toPrecision( PRECISION ) }, ${ 1 - y.toPrecision( PRECISION ) })` );
|
|
376
|
+
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return array.join( ', ' );
|
|
380
|
+
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function buildPrimvars( attributes, count ) {
|
|
384
|
+
|
|
385
|
+
let string = '';
|
|
386
|
+
|
|
387
|
+
for ( let i = 0; i < 4; i ++ ) {
|
|
388
|
+
|
|
389
|
+
const id = ( i > 0 ? i : '' );
|
|
390
|
+
const attribute = attributes[ 'uv' + id ];
|
|
391
|
+
|
|
392
|
+
if ( attribute !== undefined ) {
|
|
393
|
+
|
|
394
|
+
string += `
|
|
395
|
+
texCoord2f[] primvars:st${ id } = [${ buildVector2Array( attribute, count )}] (
|
|
396
|
+
interpolation = "vertex"
|
|
397
|
+
)`;
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return string;
|
|
404
|
+
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Materials
|
|
408
|
+
|
|
409
|
+
function buildMaterials( materials, textures, quickLookCompatible = false ) {
|
|
410
|
+
|
|
411
|
+
const array = [];
|
|
412
|
+
|
|
413
|
+
for ( const uuid in materials ) {
|
|
414
|
+
|
|
415
|
+
const material = materials[ uuid ];
|
|
416
|
+
|
|
417
|
+
array.push( buildMaterial( material, textures, quickLookCompatible ) );
|
|
418
|
+
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return `def "Materials"
|
|
422
|
+
{
|
|
423
|
+
${ array.join( '' ) }
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
`;
|
|
427
|
+
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
431
|
+
|
|
432
|
+
// https://graphics.pixar.com/usd/docs/UsdPreviewSurface-Proposal.html
|
|
433
|
+
|
|
434
|
+
const pad = ' ';
|
|
435
|
+
const inputs = [];
|
|
436
|
+
const samplers = [];
|
|
437
|
+
|
|
438
|
+
function buildTexture( texture, mapType, color ) {
|
|
439
|
+
|
|
440
|
+
const id = texture.source.id + '_' + texture.flipY;
|
|
441
|
+
|
|
442
|
+
textures[ id ] = texture;
|
|
443
|
+
|
|
444
|
+
const uv = texture.channel > 0 ? 'st' + texture.channel : 'st';
|
|
445
|
+
|
|
446
|
+
const WRAPPINGS = {
|
|
447
|
+
1000: 'repeat', // RepeatWrapping
|
|
448
|
+
1001: 'clamp', // ClampToEdgeWrapping
|
|
449
|
+
1002: 'mirror' // MirroredRepeatWrapping
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
const repeat = texture.repeat.clone();
|
|
453
|
+
const offset = texture.offset.clone();
|
|
454
|
+
const rotation = texture.rotation;
|
|
455
|
+
|
|
456
|
+
// rotation is around the wrong point. after rotation we need to shift offset again so that we're rotating around the right spot
|
|
457
|
+
const xRotationOffset = Math.sin( rotation );
|
|
458
|
+
const yRotationOffset = Math.cos( rotation );
|
|
459
|
+
|
|
460
|
+
// texture coordinates start in the opposite corner, need to correct
|
|
461
|
+
offset.y = 1 - offset.y - repeat.y;
|
|
462
|
+
|
|
463
|
+
// turns out QuickLook is buggy and interprets texture repeat inverted/applies operations in a different order.
|
|
464
|
+
// Apple Feedback: FB10036297 and FB11442287
|
|
465
|
+
if ( quickLookCompatible ) {
|
|
466
|
+
|
|
467
|
+
// This is NOT correct yet in QuickLook, but comes close for a range of models.
|
|
468
|
+
// It becomes more incorrect the bigger the offset is
|
|
469
|
+
|
|
470
|
+
offset.x = offset.x / repeat.x;
|
|
471
|
+
offset.y = offset.y / repeat.y;
|
|
472
|
+
|
|
473
|
+
offset.x += xRotationOffset / repeat.x;
|
|
474
|
+
offset.y += yRotationOffset - 1;
|
|
475
|
+
|
|
476
|
+
} else {
|
|
477
|
+
|
|
478
|
+
// results match glTF results exactly. verified correct in usdview.
|
|
479
|
+
offset.x += xRotationOffset * repeat.x;
|
|
480
|
+
offset.y += ( 1 - yRotationOffset ) * repeat.y;
|
|
481
|
+
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return `
|
|
485
|
+
def Shader "PrimvarReader_${ mapType }"
|
|
486
|
+
{
|
|
487
|
+
uniform token info:id = "UsdPrimvarReader_float2"
|
|
488
|
+
float2 inputs:fallback = (0.0, 0.0)
|
|
489
|
+
token inputs:varname = "${ uv }"
|
|
490
|
+
float2 outputs:result
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
def Shader "Transform2d_${ mapType }"
|
|
494
|
+
{
|
|
495
|
+
uniform token info:id = "UsdTransform2d"
|
|
496
|
+
token inputs:in.connect = </Materials/Material_${ material.id }/PrimvarReader_${ mapType }.outputs:result>
|
|
497
|
+
float inputs:rotation = ${ ( rotation * ( 180 / Math.PI ) ).toFixed( PRECISION ) }
|
|
498
|
+
float2 inputs:scale = ${ buildVector2( repeat ) }
|
|
499
|
+
float2 inputs:translation = ${ buildVector2( offset ) }
|
|
500
|
+
float2 outputs:result
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
def Shader "Texture_${ texture.id }_${ mapType }"
|
|
504
|
+
{
|
|
505
|
+
uniform token info:id = "UsdUVTexture"
|
|
506
|
+
asset inputs:file = @textures/Texture_${ id }.png@
|
|
507
|
+
float2 inputs:st.connect = </Materials/Material_${ material.id }/Transform2d_${ mapType }.outputs:result>
|
|
508
|
+
${ color !== undefined ? 'float4 inputs:scale = ' + buildColor4( color ) : '' }
|
|
509
|
+
token inputs:sourceColorSpace = "${ texture.colorSpace === THREE.NoColorSpace ? 'raw' : 'sRGB' }"
|
|
510
|
+
token inputs:wrapS = "${ WRAPPINGS[ texture.wrapS ] }"
|
|
511
|
+
token inputs:wrapT = "${ WRAPPINGS[ texture.wrapT ] }"
|
|
512
|
+
float outputs:r
|
|
513
|
+
float outputs:g
|
|
514
|
+
float outputs:b
|
|
515
|
+
float3 outputs:rgb
|
|
516
|
+
${ material.transparent || material.alphaTest > 0.0 ? 'float outputs:a' : '' }
|
|
517
|
+
}`;
|
|
518
|
+
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
if ( material.side === THREE.DoubleSide ) {
|
|
523
|
+
|
|
524
|
+
console.warn( 'THREE.USDZExporter: USDZ does not support double sided materials', material );
|
|
525
|
+
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if ( material.map !== null ) {
|
|
529
|
+
|
|
530
|
+
inputs.push( `${ pad }color3f inputs:diffuseColor.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:rgb>` );
|
|
531
|
+
|
|
532
|
+
if ( material.transparent ) {
|
|
533
|
+
|
|
534
|
+
inputs.push( `${ pad }float inputs:opacity.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:a>` );
|
|
535
|
+
|
|
536
|
+
} else if ( material.alphaTest > 0.0 ) {
|
|
537
|
+
|
|
538
|
+
inputs.push( `${ pad }float inputs:opacity.connect = </Materials/Material_${ material.id }/Texture_${ material.map.id }_diffuse.outputs:a>` );
|
|
539
|
+
inputs.push( `${ pad }float inputs:opacityThreshold = ${material.alphaTest}` );
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
samplers.push( buildTexture( material.map, 'diffuse', material.color ) );
|
|
544
|
+
|
|
545
|
+
} else {
|
|
546
|
+
|
|
547
|
+
inputs.push( `${ pad }color3f inputs:diffuseColor = ${ buildColor( material.color ) }` );
|
|
548
|
+
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if ( material.emissiveMap !== null ) {
|
|
552
|
+
|
|
553
|
+
inputs.push( `${ pad }color3f inputs:emissiveColor.connect = </Materials/Material_${ material.id }/Texture_${ material.emissiveMap.id }_emissive.outputs:rgb>` );
|
|
554
|
+
|
|
555
|
+
samplers.push( buildTexture( material.emissiveMap, 'emissive' ) );
|
|
556
|
+
|
|
557
|
+
} else if ( material.emissive.getHex() > 0 ) {
|
|
558
|
+
|
|
559
|
+
inputs.push( `${ pad }color3f inputs:emissiveColor = ${ buildColor( material.emissive ) }` );
|
|
560
|
+
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if ( material.normalMap !== null ) {
|
|
564
|
+
|
|
565
|
+
inputs.push( `${ pad }normal3f inputs:normal.connect = </Materials/Material_${ material.id }/Texture_${ material.normalMap.id }_normal.outputs:rgb>` );
|
|
566
|
+
|
|
567
|
+
samplers.push( buildTexture( material.normalMap, 'normal' ) );
|
|
568
|
+
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if ( material.aoMap !== null ) {
|
|
572
|
+
|
|
573
|
+
inputs.push( `${ pad }float inputs:occlusion.connect = </Materials/Material_${ material.id }/Texture_${ material.aoMap.id }_occlusion.outputs:r>` );
|
|
574
|
+
|
|
575
|
+
samplers.push( buildTexture( material.aoMap, 'occlusion' ) );
|
|
576
|
+
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if ( material.roughnessMap !== null && material.roughness === 1 ) {
|
|
580
|
+
|
|
581
|
+
inputs.push( `${ pad }float inputs:roughness.connect = </Materials/Material_${ material.id }/Texture_${ material.roughnessMap.id }_roughness.outputs:g>` );
|
|
582
|
+
|
|
583
|
+
samplers.push( buildTexture( material.roughnessMap, 'roughness' ) );
|
|
584
|
+
|
|
585
|
+
} else {
|
|
586
|
+
|
|
587
|
+
inputs.push( `${ pad }float inputs:roughness = ${ material.roughness }` );
|
|
588
|
+
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
if ( material.metalnessMap !== null && material.metalness === 1 ) {
|
|
592
|
+
|
|
593
|
+
inputs.push( `${ pad }float inputs:metallic.connect = </Materials/Material_${ material.id }/Texture_${ material.metalnessMap.id }_metallic.outputs:b>` );
|
|
594
|
+
|
|
595
|
+
samplers.push( buildTexture( material.metalnessMap, 'metallic' ) );
|
|
596
|
+
|
|
597
|
+
} else {
|
|
598
|
+
|
|
599
|
+
inputs.push( `${ pad }float inputs:metallic = ${ material.metalness }` );
|
|
600
|
+
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
if ( material.alphaMap !== null ) {
|
|
604
|
+
|
|
605
|
+
inputs.push( `${pad}float inputs:opacity.connect = </Materials/Material_${material.id}/Texture_${material.alphaMap.id}_opacity.outputs:r>` );
|
|
606
|
+
inputs.push( `${pad}float inputs:opacityThreshold = 0.0001` );
|
|
607
|
+
|
|
608
|
+
samplers.push( buildTexture( material.alphaMap, 'opacity' ) );
|
|
609
|
+
|
|
610
|
+
} else {
|
|
611
|
+
|
|
612
|
+
inputs.push( `${pad}float inputs:opacity = ${material.opacity}` );
|
|
613
|
+
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if ( material.isMeshPhysicalMaterial ) {
|
|
617
|
+
|
|
618
|
+
inputs.push( `${ pad }float inputs:clearcoat = ${ material.clearcoat }` );
|
|
619
|
+
inputs.push( `${ pad }float inputs:clearcoatRoughness = ${ material.clearcoatRoughness }` );
|
|
620
|
+
inputs.push( `${ pad }float inputs:ior = ${ material.ior }` );
|
|
621
|
+
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return `
|
|
625
|
+
def Material "Material_${ material.id }"
|
|
626
|
+
{
|
|
627
|
+
def Shader "PreviewSurface"
|
|
628
|
+
{
|
|
629
|
+
uniform token info:id = "UsdPreviewSurface"
|
|
630
|
+
${ inputs.join( '\n' ) }
|
|
631
|
+
int inputs:useSpecularWorkflow = 0
|
|
632
|
+
token outputs:surface
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
token outputs:surface.connect = </Materials/Material_${ material.id }/PreviewSurface.outputs:surface>
|
|
636
|
+
|
|
637
|
+
${ samplers.join( '\n' ) }
|
|
638
|
+
|
|
639
|
+
}
|
|
640
|
+
`;
|
|
641
|
+
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function buildColor( color ) {
|
|
645
|
+
|
|
646
|
+
return `(${ color.r }, ${ color.g }, ${ color.b })`;
|
|
647
|
+
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function buildColor4( color ) {
|
|
651
|
+
|
|
652
|
+
return `(${ color.r }, ${ color.g }, ${ color.b }, 1.0)`;
|
|
653
|
+
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function buildVector2( vector ) {
|
|
657
|
+
|
|
658
|
+
return `(${ vector.x }, ${ vector.y })`;
|
|
659
|
+
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
function buildCamera( camera ) {
|
|
664
|
+
|
|
665
|
+
const name = camera.name ? camera.name : 'Camera_' + camera.id;
|
|
666
|
+
|
|
667
|
+
const transform = buildMatrix( camera.matrixWorld );
|
|
668
|
+
|
|
669
|
+
if ( camera.matrixWorld.determinant() < 0 ) {
|
|
670
|
+
|
|
671
|
+
console.warn( 'THREE.USDZExporter: USDZ does not support negative scales', camera );
|
|
672
|
+
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if ( camera.isOrthographicCamera ) {
|
|
676
|
+
|
|
677
|
+
return `def Camera "${name}"
|
|
678
|
+
{
|
|
679
|
+
matrix4d xformOp:transform = ${ transform }
|
|
680
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
681
|
+
|
|
682
|
+
float2 clippingRange = (${ camera.near.toPrecision( PRECISION ) }, ${ camera.far.toPrecision( PRECISION ) })
|
|
683
|
+
float horizontalAperture = ${ ( ( Math.abs( camera.left ) + Math.abs( camera.right ) ) * 10 ).toPrecision( PRECISION ) }
|
|
684
|
+
float verticalAperture = ${ ( ( Math.abs( camera.top ) + Math.abs( camera.bottom ) ) * 10 ).toPrecision( PRECISION ) }
|
|
685
|
+
token projection = "orthographic"
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
`;
|
|
689
|
+
|
|
690
|
+
} else {
|
|
691
|
+
|
|
692
|
+
return `def Camera "${name}"
|
|
693
|
+
{
|
|
694
|
+
matrix4d xformOp:transform = ${ transform }
|
|
695
|
+
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
696
|
+
|
|
697
|
+
float2 clippingRange = (${ camera.near.toPrecision( PRECISION ) }, ${ camera.far.toPrecision( PRECISION ) })
|
|
698
|
+
float focalLength = ${ camera.getFocalLength().toPrecision( PRECISION ) }
|
|
699
|
+
float focusDistance = ${ camera.focus.toPrecision( PRECISION ) }
|
|
700
|
+
float horizontalAperture = ${ camera.getFilmWidth().toPrecision( PRECISION ) }
|
|
701
|
+
token projection = "perspective"
|
|
702
|
+
float verticalAperture = ${ camera.getFilmHeight().toPrecision( PRECISION ) }
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
`;
|
|
706
|
+
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export { USDZExporter };
|