chorama 0.0.0 → 0.1.1
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/.github/workflows/publish.yml +24 -0
- package/.github/workflows/static.yml +22 -53
- package/README.md +3 -1
- package/assets/models/glb/AlphaBlendModeTest.glb +0 -0
- package/assets/models/glb/IridescenceLamp.glb +0 -0
- package/assets/models/glb/teapot.glb +0 -0
- package/astro.config.mjs +9 -21
- package/content/guide/render-targets-and-views.md +3 -4
- package/content/guide/textures-and-assets.md +5 -2
- package/dist/index.module.js +23336 -0
- package/dist/index.module.js.map +1 -0
- package/dist/index.umd.js +23610 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/website/_astro/DocLayout.BsV7p0dY.css +1 -0
- package/dist/website/examples/camera/orthographic/example.html +172 -0
- package/dist/website/examples/camera/orthographic/index.html +124 -0
- package/dist/website/examples/camera/perspective/example.html +190 -0
- package/dist/website/examples/camera/perspective/index.html +142 -0
- package/dist/website/examples/camera/tone_mapping/example.html +238 -0
- package/dist/website/examples/camera/tone_mapping/index.html +190 -0
- package/dist/website/examples/index.html +2 -0
- package/dist/website/examples/lights/directional/example.html +447 -0
- package/dist/website/examples/lights/directional/index.html +399 -0
- package/dist/website/examples/lights/multiple_spot_lights/example.html +356 -0
- package/dist/website/examples/lights/multiple_spot_lights/index.html +308 -0
- package/dist/website/examples/lights/point/example.html +387 -0
- package/dist/website/examples/lights/point/index.html +339 -0
- package/dist/website/examples/lights/spot/example.html +416 -0
- package/dist/website/examples/lights/spot/index.html +368 -0
- package/dist/website/examples/loader/gltf/basic/example.html +129 -0
- package/dist/website/examples/loader/gltf/basic/index.html +81 -0
- package/dist/website/examples/loader/gltf/material/alpha-blend-mode/example.html +131 -0
- package/dist/website/examples/loader/gltf/material/alpha-blend-mode/index.html +83 -0
- package/dist/website/examples/loader/gltf/material/flight_helmet/example.html +162 -0
- package/dist/website/examples/loader/gltf/material/flight_helmet/index.html +114 -0
- package/dist/website/examples/loader/gltf/material/iridescence_lamp/example.html +169 -0
- package/dist/website/examples/loader/gltf/material/iridescence_lamp/index.html +121 -0
- package/dist/website/examples/loader/objloader/example.html +144 -0
- package/dist/website/examples/loader/objloader/index.html +96 -0
- package/dist/website/examples/material/cullface/example.html +163 -0
- package/dist/website/examples/material/cullface/index.html +115 -0
- package/dist/website/examples/material/materials/example.html +175 -0
- package/dist/website/examples/material/materials/index.html +127 -0
- package/dist/website/examples/material/standard/basic/example.html +212 -0
- package/dist/website/examples/material/standard/basic/index.html +164 -0
- package/dist/website/examples/material/standard/reflection_refraction/example.html +241 -0
- package/dist/website/examples/material/standard/reflection_refraction/index.html +193 -0
- package/dist/website/examples/mesh/capsule/example.html +173 -0
- package/dist/website/examples/mesh/capsule/index.html +125 -0
- package/dist/website/examples/mesh/circle/example.html +173 -0
- package/dist/website/examples/mesh/circle/index.html +125 -0
- package/dist/website/examples/mesh/cone/example.html +180 -0
- package/dist/website/examples/mesh/cone/index.html +132 -0
- package/dist/website/examples/mesh/cuboid/example.html +207 -0
- package/dist/website/examples/mesh/cuboid/index.html +159 -0
- package/dist/website/examples/mesh/cylinder/example.html +195 -0
- package/dist/website/examples/mesh/cylinder/index.html +147 -0
- package/dist/website/examples/mesh/dodecahedron/example.html +158 -0
- package/dist/website/examples/mesh/dodecahedron/index.html +110 -0
- package/dist/website/examples/mesh/ellipsoid/example.html +179 -0
- package/dist/website/examples/mesh/ellipsoid/index.html +131 -0
- package/dist/website/examples/mesh/extrude/example.html +169 -0
- package/dist/website/examples/mesh/extrude/index.html +121 -0
- package/dist/website/examples/mesh/frustum/example.html +185 -0
- package/dist/website/examples/mesh/frustum/index.html +137 -0
- package/dist/website/examples/mesh/helix/example.html +184 -0
- package/dist/website/examples/mesh/helix/index.html +136 -0
- package/dist/website/examples/mesh/icosahedron/example.html +158 -0
- package/dist/website/examples/mesh/icosahedron/index.html +110 -0
- package/dist/website/examples/mesh/icosphere/example.html +163 -0
- package/dist/website/examples/mesh/icosphere/index.html +115 -0
- package/dist/website/examples/mesh/lathe/example.html +175 -0
- package/dist/website/examples/mesh/lathe/index.html +127 -0
- package/dist/website/examples/mesh/meshTopology/example.html +210 -0
- package/dist/website/examples/mesh/meshTopology/index.html +162 -0
- package/dist/website/examples/mesh/octahedron/example.html +158 -0
- package/dist/website/examples/mesh/octahedron/index.html +110 -0
- package/dist/website/examples/mesh/plane/example.html +173 -0
- package/dist/website/examples/mesh/plane/index.html +125 -0
- package/dist/website/examples/mesh/prism/example.html +173 -0
- package/dist/website/examples/mesh/prism/index.html +125 -0
- package/dist/website/examples/mesh/pyramid/example.html +172 -0
- package/dist/website/examples/mesh/pyramid/index.html +124 -0
- package/dist/website/examples/mesh/ring/example.html +173 -0
- package/dist/website/examples/mesh/ring/index.html +125 -0
- package/dist/website/examples/mesh/skinning/example.html +187 -0
- package/dist/website/examples/mesh/skinning/index.html +139 -0
- package/dist/website/examples/mesh/terrain/example.html +214 -0
- package/dist/website/examples/mesh/terrain/index.html +166 -0
- package/dist/website/examples/mesh/tetrahedron/example.html +158 -0
- package/dist/website/examples/mesh/tetrahedron/index.html +110 -0
- package/dist/website/examples/mesh/torus/example.html +173 -0
- package/dist/website/examples/mesh/torus/index.html +125 -0
- package/dist/website/examples/mesh/torus-knot/example.html +188 -0
- package/dist/website/examples/mesh/torus-knot/index.html +140 -0
- package/dist/website/examples/mesh/tube/example.html +180 -0
- package/dist/website/examples/mesh/tube/index.html +132 -0
- package/dist/website/examples/mesh/uvsphere/example.html +169 -0
- package/dist/website/examples/mesh/uvsphere/index.html +121 -0
- package/dist/website/examples/mesh/wedge/example.html +168 -0
- package/dist/website/examples/mesh/wedge/index.html +120 -0
- package/dist/website/examples/other/rotatingCube/example.html +142 -0
- package/dist/website/examples/other/rotatingCube/index.html +94 -0
- package/dist/website/examples/other/rotatingSphere/example.html +144 -0
- package/dist/website/examples/other/rotatingSphere/index.html +96 -0
- package/dist/website/examples/rendertarget/basic_canvas/example.html +178 -0
- package/dist/website/examples/rendertarget/basic_canvas/index.html +130 -0
- package/dist/website/examples/rendertarget/depth_texture/example.html +188 -0
- package/dist/website/examples/rendertarget/depth_texture/index.html +140 -0
- package/dist/website/examples/rendertarget/image_target/example.html +196 -0
- package/dist/website/examples/rendertarget/image_target/index.html +148 -0
- package/dist/website/examples/rendertarget/multiple_views/example.html +204 -0
- package/dist/website/examples/rendertarget/multiple_views/index.html +156 -0
- package/dist/website/examples/rendertarget/render_masks/example.html +222 -0
- package/dist/website/examples/rendertarget/render_masks/index.html +174 -0
- package/dist/website/examples/rendertarget/split_screen/example.html +178 -0
- package/dist/website/examples/rendertarget/split_screen/index.html +130 -0
- package/dist/website/examples/rendertarget/split_view/example.html +191 -0
- package/dist/website/examples/rendertarget/split_view/index.html +143 -0
- package/dist/website/examples/skybox/skybox/example.html +162 -0
- package/dist/website/examples/skybox/skybox/index.html +114 -0
- package/dist/website/examples/texture/arrays/example.html +204 -0
- package/dist/website/examples/texture/arrays/index.html +156 -0
- package/dist/website/examples/texture/textureWrap/example.html +169 -0
- package/dist/website/examples/texture/textureWrap/index.html +121 -0
- package/dist/website/examples/transform/propagation/example.html +141 -0
- package/dist/website/examples/transform/propagation/index.html +93 -0
- package/dist/website/guide/api-map/index.html +82 -0
- package/dist/website/guide/camera-and-controls/index.html +62 -0
- package/dist/website/guide/first-scene/index.html +119 -0
- package/dist/website/guide/index.html +58 -0
- package/dist/website/guide/installation/index.html +133 -0
- package/dist/website/guide/materials-and-lighting/index.html +90 -0
- package/dist/website/guide/plugins-and-render-pipeline/index.html +89 -0
- package/dist/website/guide/render-targets-and-views/index.html +95 -0
- package/dist/website/guide/scene-graph-and-transforms/index.html +69 -0
- package/dist/website/guide/textures-and-assets/index.html +85 -0
- package/dist/website/guide/troubleshooting/index.html +39 -0
- package/dist/website/images/disappointed.jpg +0 -0
- package/dist/website/images/skybox/grimmnight_back.png +0 -0
- package/dist/website/images/skybox/grimmnight_bottom.png +0 -0
- package/dist/website/images/skybox/grimmnight_front.png +0 -0
- package/dist/website/images/skybox/grimmnight_left.png +0 -0
- package/dist/website/images/skybox/grimmnight_right.png +0 -0
- package/dist/website/images/skybox/grimmnight_top.png +0 -0
- package/dist/website/images/skybox/miramar_back.png +0 -0
- package/dist/website/images/skybox/miramar_bottom.png +0 -0
- package/dist/website/images/skybox/miramar_front.png +0 -0
- package/dist/website/images/skybox/miramar_left.png +0 -0
- package/dist/website/images/skybox/miramar_right.png +0 -0
- package/dist/website/images/skybox/miramar_top.png +0 -0
- package/dist/website/images/uv.jpg +0 -0
- package/dist/website/index.html +157 -0
- package/dist/website/models/glb/AlphaBlendModeTest.glb +0 -0
- package/dist/website/models/glb/IridescenceLamp.glb +0 -0
- package/dist/website/models/glb/teapot.glb +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_BaseColor.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_Normal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_OcclusionRoughMetal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_BaseColor.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_Normal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_OcclusionRoughMetal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_BaseColor.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_Normal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_BaseColor.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_Normal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_OcclusionRoughMetal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_BaseColor.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_Normal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_OcclusionRoughMetal.png +0 -0
- package/dist/website/models/gltf/flight_helmet/index.bin +0 -0
- package/dist/website/models/gltf/flight_helmet/index.gltf +705 -0
- package/dist/website/models/gltf/object.gltf +23 -0
- package/dist/website/models/gltf/pirate_girl/index.bin +0 -0
- package/dist/website/models/gltf/pirate_girl/index.gltf +2082 -0
- package/dist/website/models/obj/pirate_girl/pirate_girl.obj +18459 -0
- package/dist/website/models/obj/pirate_girl/pirate_girl.png +0 -0
- package/env.d.ts +0 -14
- package/examples/camera/orthographic.js +2 -1
- package/examples/camera/perspective.js +2 -1
- package/examples/camera/tone_mapping.js +187 -0
- package/examples/lights/directional.js +2 -3
- package/examples/lights/multiple_spot_lights.js +2 -1
- package/examples/lights/point.js +2 -3
- package/examples/lights/spot.js +2 -3
- package/examples/loader/{gltfloader.js → gltf/basic.js} +8 -8
- package/examples/loader/gltf/material/alpha-blend-mode.js +80 -0
- package/examples/loader/{gltf_material.js → gltf/material/flight_helmet.js} +8 -8
- package/examples/loader/gltf/material/iridescence_lamp.js +118 -0
- package/examples/loader/objloader.js +9 -11
- package/examples/material/cullface.js +8 -7
- package/examples/material/materials.js +9 -11
- package/examples/material/standard/basic.js +3 -6
- package/examples/material/standard/reflection_refraction.js +190 -0
- package/examples/mesh/capsule.js +122 -0
- package/examples/mesh/circle.js +11 -6
- package/examples/mesh/cone.js +129 -0
- package/examples/mesh/cuboid.js +11 -6
- package/examples/mesh/cylinder.js +11 -6
- package/examples/mesh/dodecahedron.js +107 -0
- package/examples/mesh/ellipsoid.js +128 -0
- package/examples/mesh/extrude.js +118 -0
- package/examples/mesh/frustum.js +134 -0
- package/examples/mesh/helix.js +133 -0
- package/examples/mesh/icosahedron.js +107 -0
- package/examples/mesh/icosphere.js +112 -0
- package/examples/mesh/lathe.js +124 -0
- package/examples/mesh/meshTopology.js +64 -8
- package/examples/mesh/octahedron.js +107 -0
- package/examples/mesh/plane.js +11 -6
- package/examples/mesh/prism.js +122 -0
- package/examples/mesh/pyramid.js +121 -0
- package/examples/mesh/ring.js +122 -0
- package/examples/mesh/skinning.js +8 -8
- package/examples/mesh/terrain.js +163 -0
- package/examples/mesh/tetrahedron.js +107 -0
- package/examples/mesh/torus-knot.js +137 -0
- package/examples/mesh/torus.js +122 -0
- package/examples/mesh/tube.js +129 -0
- package/examples/mesh/uvsphere.js +11 -6
- package/examples/mesh/wedge.js +117 -0
- package/examples/other/rotatingCube.js +9 -11
- package/examples/other/rotatingSphere.js +9 -12
- package/examples/rendertarget/basic_canvas.js +5 -8
- package/examples/rendertarget/depth_texture.js +18 -11
- package/examples/rendertarget/image_target.js +19 -14
- package/examples/rendertarget/multiple_views.js +11 -16
- package/examples/rendertarget/render_masks.js +3 -5
- package/examples/rendertarget/split_screen.js +18 -14
- package/examples/rendertarget/split_view.js +12 -9
- package/examples/skybox/skybox.js +8 -8
- package/examples/texture/arrays.js +9 -12
- package/examples/texture/textureWrap.js +8 -8
- package/examples/transform/propagation.js +9 -11
- package/package.json +18 -12
- package/src/caches/cache.js +121 -182
- package/src/caches/uniformbuffers.js +42 -53
- package/src/constants/texture.js +1 -1
- package/src/content.config.js +1 -0
- package/src/core/layouts/bindgroup.js +167 -0
- package/src/core/layouts/index.js +3 -1
- package/src/core/layouts/pipeline.js +165 -0
- package/src/core/layouts/uniformbuffer.js +11 -3
- package/src/core/resources/gpubuffer.js +23 -2
- package/src/core/resources/gpumesh.js +37 -4
- package/src/core/resources/gpusampler.js +43 -0
- package/src/core/resources/gputexture.js +31 -2
- package/src/core/resources/index.js +4 -2
- package/src/core/resources/newuniformbuffer.js +58 -0
- package/src/core/resources/webglshadermodule.js +58 -0
- package/src/core/shader.js +24 -11
- package/src/core/webgl/bindgroup.js +200 -42
- package/src/core/webgl/descriptors.js +87 -25
- package/src/core/webgl/gpuqueue.js +63 -0
- package/src/core/webgl/index.js +3 -0
- package/src/core/webgl/renderpassencoder.js +703 -16
- package/src/core/webgl/renderpipeline.js +38 -1
- package/src/core/webgl/utils.js +207 -57
- package/src/core/webgl/webglrenderdevice.js +77 -53
- package/src/loader/gltf.js +716 -166
- package/src/loader/texture.js +69 -16
- package/src/loader/utils.js +44 -0
- package/src/material/alphablend.js +21 -0
- package/src/material/basic.js +15 -1
- package/src/material/depth.js +15 -1
- package/src/material/index.js +1 -0
- package/src/material/lambert.js +15 -1
- package/src/material/material.js +49 -7
- package/src/material/normal.js +14 -0
- package/src/material/phong.js +16 -2
- package/src/material/raw.js +21 -2
- package/src/material/standard.js +90 -2
- package/src/mesh/attribute/attribute.js +2 -2
- package/src/mesh/attributedata/separate.js +2 -2
- package/src/mesh/builders/capsule.js +47 -0
- package/src/mesh/builders/cone.js +29 -0
- package/src/mesh/builders/dodecahedron.js +130 -0
- package/src/mesh/builders/ellipsoid.js +65 -0
- package/src/mesh/builders/extrude.js +136 -0
- package/src/mesh/builders/frustum.js +26 -0
- package/src/mesh/builders/geometry.js +121 -0
- package/src/mesh/builders/helix.js +35 -0
- package/src/mesh/builders/icosahedron.js +61 -0
- package/src/mesh/builders/icosphere.js +141 -0
- package/src/mesh/builders/index.js +22 -1
- package/src/mesh/builders/lathe.js +85 -0
- package/src/mesh/builders/octahedron.js +43 -0
- package/src/mesh/builders/polyhedron.js +121 -0
- package/src/mesh/builders/prism.js +19 -0
- package/src/mesh/builders/pyramid.js +90 -0
- package/src/mesh/builders/ring.js +109 -0
- package/src/mesh/builders/surfaces.js +69 -0
- package/src/mesh/builders/terrain.js +80 -0
- package/src/mesh/builders/tetrahedron.js +37 -0
- package/src/mesh/builders/torusknot.js +36 -0
- package/src/mesh/builders/tube.js +209 -0
- package/src/mesh/builders/utils.js +130 -2
- package/src/mesh/builders/wedge.js +22 -0
- package/src/mesh/mesh.js +12 -4
- package/src/objects/camera/camera.js +104 -1
- package/src/objects/light/ambient.js +22 -1
- package/src/objects/light/directional.js +23 -1
- package/src/objects/light/point.js +25 -1
- package/src/objects/light/spot.js +27 -1
- package/src/objects/mesh.js +1 -53
- package/src/plugins/camera/RenderTarget2DPool.js +94 -0
- package/src/plugins/camera/camera.js +14 -6
- package/src/plugins/camera/index.js +2 -0
- package/src/plugins/camera/nodes/canvasblit.js +153 -0
- package/src/plugins/camera/nodes/index.js +4 -1
- package/src/plugins/camera/nodes/opaquepass.js +48 -33
- package/src/plugins/camera/nodes/tonemapping.js +217 -0
- package/src/plugins/camera/nodes/transparentpass.js +87 -0
- package/src/plugins/camera/nodes/{cameraview.js → view.js} +27 -1
- package/src/plugins/camera/resources/cameracolortargets.js +66 -0
- package/src/plugins/camera/resources/canvasblitpipeline.js +6 -0
- package/src/plugins/camera/resources/index.js +3 -0
- package/src/plugins/camera/resources/tonemappingpipeline.js +6 -0
- package/src/plugins/light/light.js +0 -4
- package/src/plugins/meshmaterial/meshmaterial.js +433 -170
- package/src/plugins/meshmaterial/nodes/meshmaterial.js +39 -6
- package/src/plugins/meshmaterial/resources/bonetexture.js +176 -0
- package/src/plugins/meshmaterial/resources/environmentmap.js +44 -0
- package/src/plugins/meshmaterial/resources/index.js +4 -0
- package/src/plugins/meshmaterial/resources/materialuniformbuffers.js +94 -0
- package/src/plugins/meshmaterial/resources/meshmaterialbindgroups.js +40 -0
- package/src/plugins/shadow/nodes/index.js +3 -3
- package/src/plugins/shadow/nodes/{shadowOccluder.js → occluder.js} +13 -19
- package/src/plugins/shadow/nodes/opaquePass.js +110 -0
- package/src/plugins/shadow/shadow.js +0 -5
- package/src/plugins/skeletonhelper/skeletonhelper.js +111 -69
- package/src/plugins/skybox/nodes/skybox.js +230 -38
- package/src/plugins/skybox/resources/skyboxpipeline.js +10 -0
- package/src/plugins/skybox/skybox.js +0 -119
- package/src/renderer/core/index.js +135 -21
- package/src/renderer/plugin.js +0 -20
- package/src/renderer/renderer.js +28 -12
- package/src/rendertarget/canvastarget.js +8 -5
- package/src/rendertarget/image.js +3 -3
- package/src/shader/basicFragment.glsl +12 -4
- package/src/shader/basicVertex.glsl +26 -15
- package/src/shader/blitFragment.glsl +9 -0
- package/src/shader/common/common.glsl +35 -6
- package/src/shader/common/index.js +1 -0
- package/src/shader/common/tonemap.glsl +118 -0
- package/src/shader/debug/skeletonFragment.glsl +0 -2
- package/src/shader/debug/skeletonVertex.glsl +1 -3
- package/src/shader/depthFragment.glsl +0 -3
- package/src/shader/fullscreenVertex.glsl +26 -0
- package/src/shader/index.js +3 -0
- package/src/shader/lambertFragment.glsl +12 -4
- package/src/shader/normalFragment.glsl +0 -3
- package/src/shader/phongFragment.glsl +12 -4
- package/src/shader/skyboxFragment.glsl +5 -5
- package/src/shader/skyboxVertex.glsl +5 -4
- package/src/shader/standardFragment.glsl +74 -17
- package/src/shader/tonemappingFragment.glsl +37 -0
- package/src/texture/sampler.js +101 -21
- package/src/texture/texture.js +252 -48
- package/src/utils/index.js +15 -1
- package/{examples/addons → src/utils}/rendergraph_gui.js +5 -2
- package/examples/mesh/geometries.js +0 -108
- package/scripts/stage-chorama.mjs +0 -29
- package/src/core/resources/framebuffer.js +0 -127
- package/src/plugins/shadow/nodes/shadowOpaquePass.js +0 -73
- package/website/config/index.ts +0 -1
- package/website/config/navigation.ts +0 -53
- package/website/content.config.ts +0 -92
- package/website/layouts/DocLayout.astro +0 -501
- package/website/layouts/Example.astro +0 -91
- package/website/pages/examples/[...slug].astro +0 -77
- package/website/pages/examples/index.astro +0 -98
- package/website/pages/examples/samples/[...slug].astro +0 -17
- package/website/pages/guide/[slug].astro +0 -30
- package/website/pages/guide/index.astro +0 -21
- package/website/pages/index.astro +0 -9
- package/website/plugins/remark-link-base.js +0 -23
- package/website/utils/url.ts +0 -30
- /package/src/plugins/shadow/nodes/{shadow.js → view.js} +0 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
<!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width"><meta name="generator" content="Astro v7.2.2"><title>Depth Texture | chorama</title><style>.category-section[data-astro-cid-mzi2nk5r]+.category-section[data-astro-cid-mzi2nk5r]{margin-top:2rem}.category-section[data-astro-cid-mzi2nk5r] h2[data-astro-cid-mzi2nk5r]{margin-bottom:.75rem}.examples-grid[data-astro-cid-mzi2nk5r]{grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:1rem;margin-top:1.5rem;display:grid}.example-card[data-astro-cid-mzi2nk5r]{aspect-ratio:4/3;border:1px solid var(--border);background:var(--surface-2);border-radius:0;text-decoration:none;display:block;position:relative;overflow:hidden}.example-card[data-astro-cid-mzi2nk5r] img[data-astro-cid-mzi2nk5r]{object-fit:cover;width:100%;height:100%;display:block}.example-card[data-astro-cid-mzi2nk5r] span[data-astro-cid-mzi2nk5r]{text-align:center;color:#fff;background:linear-gradient(#00000026,#000c);padding:.55rem .75rem;font-weight:700;position:absolute;bottom:0;left:0;right:0}.example-frame[data-astro-cid-mxkslj3q]{width:100%;margin-bottom:1.25rem;position:relative}.example-link[data-astro-cid-mxkslj3q]{z-index:1;color:var(--accent);background:#00000059;border-radius:0;padding:.2rem .5rem;font-weight:600;text-decoration:underline;position:absolute;top:7rem;left:50%;transform:translate(-50%)}.example-link[data-astro-cid-mxkslj3q]:hover{color:var(--accent-secondary)}.source-code[data-astro-cid-mxkslj3q]{outline:1px solid var(--border);outline-offset:0;border-radius:0;overflow:hidden}.example-preview[data-astro-cid-mxkslj3q]{border:1px solid var(--border);background:#fff;border-radius:0;width:100%;height:560px;margin:0 0 1.25rem;display:block}.source-code[data-astro-cid-mxkslj3q] .astro-code{border:0!important;border-radius:0!important}.source-code[data-astro-cid-mxkslj3q] pre{padding:10px;margin:0!important}
|
|
2
|
+
</style><link rel="stylesheet" href="/_astro/DocLayout.BsV7p0dY.css"></head> <body> <div class="shell"> <button class="menu-toggle" id="menu-toggle" type="button" aria-label="Toggle menu" aria-expanded="false" aria-controls="site-sidebar"> <span></span> <span></span> <span></span> </button> <aside id="site-sidebar" aria-label="Sidebar navigation"> <p class="tabs-title">Navigation</p> <div><ul class="tabs"><li class="tab-item"><details class="tab-group"><summary class="tab-toggle"><span>Introduction</span><span class="chevron">›</span></summary><ul class="tabs"><li class="tab-item"><a href="/#features">Features</a></li><li class="tab-item"><a href="/#who-this-is-for">Who This Is For</a></li><li class="tab-item"><a href="/#getting-started">Getting Started</a><ul class="subtabs" hidden><li class="tab-item"><a href="/#requirements">Requirements</a></li><li class="tab-item"><a href="/#install-dependencies">Install dependencies</a></li><li class="tab-item"><a href="/#build-library-bundles">Build library bundles</a></li><li class="tab-item"><a href="/#run-demos">Run demos</a></li></ul></li><li class="tab-item"><a href="/#core-usage-flow">Core Usage Flow</a></li></ul></details></li><li class="tab-item"><details class="tab-group"><summary class="tab-toggle"><span>Guide</span><span class="chevron">›</span></summary><ul class="tabs"><li class="tab-item"><a href="/guide">Overview</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide#who-this-guide-is-for">Who This Guide Is For</a></li><li class="tab-item"><a href="/guide#how-to-use-this-guide">How To Use This Guide</a></li><li class="tab-item"><a href="/guide#reading-order">Reading Order</a></li><li class="tab-item"><a href="/guide#core-flow">Core Flow</a></li></ul></li><li class="tab-item"><a href="/guide/installation">Installation</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#npm">NPM</a></li><li class="tab-item"><a href="/guide/installation#cdn">CDN</a></li><li class="tab-item"><a href="/guide/installation#manual-installation">Manual Installation</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#1-requirements">Requirements</a></li><li class="tab-item"><a href="/guide/installation#2-clone-the-repository-and-install-dependencies">Clone the repository and install dependencies</a></li><li class="tab-item"><a href="/guide/installation#3-build-the-library-files">Build the library files</a></li><li class="tab-item"><a href="/guide/installation#4-copy-files-to-your-project">Copy files to your project</a></li><li class="tab-item"><a href="/guide/installation#5-use-in-your-project">Use in your project</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#esm-recommended">ESM (recommended)</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/installation#vite-viteconfigjs">Vite (vite.config.js)</a></li><li class="tab-item"><a href="/guide/installation#webpack-webpackconfigjs">Webpack (webpack.config.js)</a></li></ul></li><li class="tab-item"><a href="/guide/installation#plain-html-with-browser-import-maps-no-bundler">Plain HTML with browser import maps (no bundler)</a></li><li class="tab-item"><a href="/guide/installation#plain-html-with-script-tag-umd">Plain HTML with script tag (UMD)</a></li></ul></li></ul></li></ul></li><li class="tab-item"><a href="/guide/first-scene">First Scene</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/first-scene#what-you-will-build">What You Will Build</a></li><li class="tab-item"><a href="/guide/first-scene#before-you-start">Before You Start</a></li><li class="tab-item"><a href="/guide/first-scene#build-your-first-scene">Build Your first scene</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/first-scene#step-1-import-what-you-need">Step 1: Import what you need</a></li><li class="tab-item"><a href="/guide/first-scene#step-2-create-and-mount-a-canvas">Step 2: Create and mount a canvas</a></li><li class="tab-item"><a href="/guide/first-scene#step-3-create-device-and-render-target">Step 3: Create device and render target</a></li><li class="tab-item"><a href="/guide/first-scene#step-4-create-renderer-and-required-plugins">Step 4: Create renderer and required plugins</a></li><li class="tab-item"><a href="/guide/first-scene#step-5-create-and-position-a-camera">Step 5: Create and position a camera</a></li><li class="tab-item"><a href="/guide/first-scene#step-6-create-a-cube-object">Step 6: Create a cube object</a></li><li class="tab-item"><a href="/guide/first-scene#step-7-define-per-frame-rotation">Step 7: Define per-frame rotation</a></li><li class="tab-item"><a href="/guide/first-scene#step-8-add-resize-handling">Step 8: Add resize handling</a></li><li class="tab-item"><a href="/guide/first-scene#step-9-start-the-render-loop">Step 9: Start the render loop</a></li></ul></li><li class="tab-item"><a href="/guide/first-scene#what-you-can-try-next">What You Can Try Next</a></li><li class="tab-item"><a href="/guide/first-scene#reference-example">Reference Example</a></li></ul></li><li class="tab-item"><a href="/guide/camera-and-controls">Camera and Controls</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/camera-and-controls#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-1-import-camera-apis">Step 1: Import Camera APIs</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-2-create-a-camera">Step 2: Create a Camera</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-3-configure-perspective-projection">Step 3: Configure Perspective Projection</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-4-add-orbit-controls">Step 4: Add Orbit Controls</a></li><li class="tab-item"><a href="/guide/camera-and-controls#step-5-update-controls-in-the-frame-loop">Step 5: Update Controls in the Frame Loop</a></li><li class="tab-item"><a href="/guide/camera-and-controls#switch-to-orthographic-projection">Switch to Orthographic Projection</a></li><li class="tab-item"><a href="/guide/camera-and-controls#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/materials-and-lighting">Materials and Lighting</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/materials-and-lighting#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-1-import-material-and-light-apis">Step 1: Import Material and Light APIs</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-2-pick-a-material-model">Step 2: Pick a Material Model</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-3-apply-the-material-to-your-mesh-object">Step 3: Apply the Material to Your Mesh Object</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-4-enable-the-lighting-pipeline-in-the-renderer">Step 4: Enable the Lighting Pipeline in the Renderer</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-5-add-ambient-light">Step 5: Add Ambient Light</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-6-add-a-directional-light">Step 6: Add a Directional Light</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-7-render-with-object-lights-and-camera">Step 7: Render with Object, Lights, and Camera</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#step-8-animate-and-keep-scene-responsive">Step 8: Animate and Keep Scene Responsive</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#switching-between-material-types">Switching Between Material Types</a></li><li class="tab-item"><a href="/guide/materials-and-lighting#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/textures-and-assets">What You Will Add</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/textures-and-assets#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-1-import-loaders">Step 1: Import Loaders</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-2-load-a-texture">Step 2: Load a Texture</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-3-apply-the-texture-to-a-material">Step 3: Apply the Texture to a Material</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-4-load-an-obj-model">Step 4: Load an OBJ Model</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-5-optionally-patch-imported-obj-materials">Step 5: Optionally Patch Imported OBJ Materials</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-6-load-a-gltf-scene">Step 6: Load a glTF Scene</a></li><li class="tab-item"><a href="/guide/textures-and-assets#step-7-render-streaming-assets-safely">Step 7: Render Streaming Assets Safely</a></li><li class="tab-item"><a href="/guide/textures-and-assets#path-rules-that-prevent-most-loading-errors">Path Rules That Prevent Most Loading Errors</a></li><li class="tab-item"><a href="/guide/textures-and-assets#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/render-targets-and-views">Render Targets and Views</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/render-targets-and-views#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-1-import-render-target-apis">Step 1: Import Render Target APIs</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-2-create-a-canvas-target-most-common">Step 2: Create a Canvas Target (Most Common)</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-3-render-a-scene-to-the-canvas-target">Step 3: Render a Scene to the Canvas Target</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-4-create-an-offscreen-image-target">Step 4: Create an Offscreen Image Target</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-5-render-offscreen-with-a-dedicated-camera">Step 5: Render Offscreen with a Dedicated Camera</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-6-use-offscreen-output-as-a-texture">Step 6: Use Offscreen Output as a Texture</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-7-split-canvas-with-viewports">Step 7: Split Canvas with Viewports</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-8-bind-cameras-to-each-view-and-render-once">Step 8: Bind Cameras to Each View and Render Once</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#step-9-use-scissor-for-hard-splitmasking">Step 9: Use Scissor for Hard Split/Masking</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#resize-rule-for-multi-view-scenes">Resize Rule for Multi-View Scenes</a></li><li class="tab-item"><a href="/guide/render-targets-and-views#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms">Scene Graph and Transforms</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/scene-graph-and-transforms#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-1-import-what-you-need">Step 1: Import What You Need</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-2-create-parent-and-child-nodes">Step 2: Create Parent and Child Nodes</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-3-build-the-hierarchy">Step 3: Build the Hierarchy</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-4-set-local-transforms">Step 4: Set Local Transforms</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-5-animate-the-parent">Step 5: Animate the Parent</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#step-6-render-the-hierarchy">Step 6: Render the Hierarchy</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#traverse-the-graph-for-bulk-operations">Traverse the Graph for Bulk Operations</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#reparent-safely">Reparent Safely</a></li><li class="tab-item"><a href="/guide/scene-graph-and-transforms#reference-examples">Reference Examples</a></li></ul></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline">Plugins and Render Pipeline</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#what-you-will-add">What You Will Add</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-1-import-core-renderer-and-plugins">Step 1: Import Core Renderer and Plugins</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-2-build-a-minimal-plugin-stack">Step 2: Build a Minimal Plugin Stack</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-3-add-lighting-support">Step 3: Add Lighting Support</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-4-add-shadows-and-skybox-when-needed">Step 4: Add Shadows and Skybox When Needed</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#step-5-render-as-usual">Step 5: Render as Usual</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#what-happens-during-render">What Happens During render()</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#plugin-roles">Plugin Roles</a></li><li class="tab-item"><a href="/guide/plugins-and-render-pipeline#create-a-custom-plugin">Create a Custom Plugin</a></li></ul></li><li class="tab-item"><a href="/guide/api-map">API Map</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/api-map#quick-import-example">Quick Import Example</a></li><li class="tab-item"><a href="/guide/api-map#rendering-core">Rendering Core</a></li><li class="tab-item"><a href="/guide/api-map#scene-objects">Scene Objects</a></li><li class="tab-item"><a href="/guide/api-map#materials">Materials</a></li><li class="tab-item"><a href="/guide/api-map#lighting">Lighting</a></li><li class="tab-item"><a href="/guide/api-map#geometry-and-mesh">Geometry and Mesh</a></li><li class="tab-item"><a href="/guide/api-map#camera-and-control">Camera and Control</a></li><li class="tab-item"><a href="/guide/api-map#assets-and-textures">Assets and Textures</a></li><li class="tab-item"><a href="/guide/api-map#render-targets">Render Targets</a></li><li class="tab-item"><a href="/guide/api-map#plugins">Plugins</a></li></ul></li><li class="tab-item"><a href="/guide/troubleshooting">Troubleshooting</a><ul class="subtabs" hidden><li class="tab-item"><a href="/guide/troubleshooting#blank-canvas">Blank Canvas</a></li><li class="tab-item"><a href="/guide/troubleshooting#object-is-black-or-unlit">Object Is Black or Unlit</a></li><li class="tab-item"><a href="/guide/troubleshooting#distorted-aspect-ratio">Distorted Aspect Ratio</a></li><li class="tab-item"><a href="/guide/troubleshooting#missing-textures-or-models">Missing Textures or Models</a></li><li class="tab-item"><a href="/guide/troubleshooting#shadows-not-visible">Shadows Not Visible</a></li></ul></li></ul></details></li><li class="tab-item"><a href="/examples">Examples</a></li></ul></div> </aside> <main> <div class="example-frame" data-astro-cid-mxkslj3q> <a href="/examples" data-astro-cid-mxkslj3q>← Back to examples</a> <h1 style="text-align:center" data-astro-cid-mxkslj3q>Depth Texture</h1> <a class="example-link" href="/examples/rendertarget/depth_texture/example.html" target="_blank" rel="noreferrer" data-astro-cid-mxkslj3q>
|
|
3
|
+
Open as a stand-alone example
|
|
4
|
+
</a> <iframe class="example-preview" title="Depth Texture preview" src="/examples/rendertarget/depth_texture/example.html" loading="lazy" data-astro-cid-mxkslj3q></iframe> </div> <p data-astro-cid-mxkslj3q>Source file: /examples/rendertarget/depth_texture.js</p> <div class="source-code" data-astro-cid-mxkslj3q> <pre class="astro-code github-dark" style="background-color:#24292e;color:#e1e4e8; overflow-x: auto;" tabindex="0" data-astro-cid-mxkslj3q data-language="js"><code><span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { GUI } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "dat.gui"</span></span>
|
|
5
|
+
<span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> { addRenderGraphGuiAddon } </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span></span>
|
|
6
|
+
<span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> Stats </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "stats.js"</span><span style="color:#E1E4E8">;</span></span>
|
|
7
|
+
<span class="line"><span style="color:#F97583">import</span><span style="color:#E1E4E8"> {</span></span>
|
|
8
|
+
<span class="line"><span style="color:#E1E4E8"> MeshMaterial3D,</span></span>
|
|
9
|
+
<span class="line"><span style="color:#E1E4E8"> BasicMaterial,</span></span>
|
|
10
|
+
<span class="line"><span style="color:#E1E4E8"> Quaternion,</span></span>
|
|
11
|
+
<span class="line"><span style="color:#E1E4E8"> WebGLRenderer,</span></span>
|
|
12
|
+
<span class="line"><span style="color:#E1E4E8"> PerspectiveProjection,</span></span>
|
|
13
|
+
<span class="line"><span style="color:#E1E4E8"> Camera,</span></span>
|
|
14
|
+
<span class="line"><span style="color:#E1E4E8"> WebGLRenderDevice,</span></span>
|
|
15
|
+
<span class="line"><span style="color:#E1E4E8"> TextureType,</span></span>
|
|
16
|
+
<span class="line"><span style="color:#E1E4E8"> Texture,</span></span>
|
|
17
|
+
<span class="line"><span style="color:#E1E4E8"> TextureFormat,</span></span>
|
|
18
|
+
<span class="line"><span style="color:#E1E4E8"> ImageRenderTarget,</span></span>
|
|
19
|
+
<span class="line"><span style="color:#E1E4E8"> CuboidMeshBuilder,</span></span>
|
|
20
|
+
<span class="line"><span style="color:#E1E4E8"> MeshMaterialPlugin,</span></span>
|
|
21
|
+
<span class="line"><span style="color:#E1E4E8"> PlaneMeshBuilder,</span></span>
|
|
22
|
+
<span class="line"><span style="color:#E1E4E8"> DepthMaterial,</span></span>
|
|
23
|
+
<span class="line"><span style="color:#E1E4E8"> CanvasTarget,</span></span>
|
|
24
|
+
<span class="line"><span style="color:#E1E4E8"> CameraPlugin</span></span>
|
|
25
|
+
<span class="line"><span style="color:#E1E4E8">} </span><span style="color:#F97583">from</span><span style="color:#9ECBFF"> "chorama"</span></span>
|
|
26
|
+
<span class="line"></span>
|
|
27
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> canvas</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> document.</span><span style="color:#B392F0">createElement</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'canvas'</span><span style="color:#E1E4E8">)</span></span>
|
|
28
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> canvasTarget</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> CanvasTarget</span><span style="color:#E1E4E8">(canvas)</span></span>
|
|
29
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderDevice</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WebGLRenderDevice</span><span style="color:#E1E4E8">(canvas,{</span></span>
|
|
30
|
+
<span class="line"><span style="color:#E1E4E8"> depth:</span><span style="color:#79B8FF">true</span></span>
|
|
31
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
32
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderer</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> WebGLRenderer</span><span style="color:#E1E4E8">({</span></span>
|
|
33
|
+
<span class="line"><span style="color:#E1E4E8"> plugins: [</span></span>
|
|
34
|
+
<span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> CameraPlugin</span><span style="color:#E1E4E8">(),</span></span>
|
|
35
|
+
<span class="line"><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterialPlugin</span><span style="color:#E1E4E8">(),</span></span>
|
|
36
|
+
<span class="line"><span style="color:#E1E4E8"> ]</span></span>
|
|
37
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
38
|
+
<span class="line"></span>
|
|
39
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> depthTexture</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Texture</span><span style="color:#E1E4E8">({</span></span>
|
|
40
|
+
<span class="line"><span style="color:#E1E4E8"> type: TextureType.Texture2D,</span></span>
|
|
41
|
+
<span class="line"><span style="color:#E1E4E8"> format: TextureFormat.Depth24PlusStencil8</span></span>
|
|
42
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
43
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> renderTarget</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> ImageRenderTarget</span><span style="color:#E1E4E8">({</span></span>
|
|
44
|
+
<span class="line"><span style="color:#E1E4E8"> width: </span><span style="color:#79B8FF">1024</span><span style="color:#E1E4E8">,</span></span>
|
|
45
|
+
<span class="line"><span style="color:#E1E4E8"> height: </span><span style="color:#79B8FF">1024</span><span style="color:#E1E4E8">,</span></span>
|
|
46
|
+
<span class="line"><span style="color:#E1E4E8"> depthTexture: depthTexture</span></span>
|
|
47
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
48
|
+
<span class="line"></span>
|
|
49
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> camera1</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Camera</span><span style="color:#E1E4E8">(renderTarget)</span></span>
|
|
50
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> camera2</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Camera</span><span style="color:#E1E4E8">(canvasTarget)</span></span>
|
|
51
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> OFFSCREEN_VIEW</span><span style="color:#F97583"> =</span><span style="color:#79B8FF"> 0</span></span>
|
|
52
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> MAIN_VIEW</span><span style="color:#F97583"> =</span><span style="color:#79B8FF"> 1</span></span>
|
|
53
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> mesh</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> CuboidMeshBuilder</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">()</span></span>
|
|
54
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> quad</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> PlaneMeshBuilder</span><span style="color:#E1E4E8">()</span></span>
|
|
55
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> depthMaterial</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> DepthMaterial</span><span style="color:#E1E4E8">({</span></span>
|
|
56
|
+
<span class="line"><span style="color:#E1E4E8"> depth: depthTexture</span></span>
|
|
57
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
58
|
+
<span class="line"></span>
|
|
59
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> object1</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterial3D</span><span style="color:#E1E4E8">(mesh, </span><span style="color:#F97583">new</span><span style="color:#B392F0"> BasicMaterial</span><span style="color:#E1E4E8">())</span></span>
|
|
60
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> object2</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> MeshMaterial3D</span><span style="color:#E1E4E8">(quad.</span><span style="color:#B392F0">build</span><span style="color:#E1E4E8">(), depthMaterial)</span></span>
|
|
61
|
+
<span class="line"></span>
|
|
62
|
+
<span class="line"><span style="color:#E1E4E8">object1.renderMask.</span><span style="color:#B392F0">clear</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">on</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">OFFSCREEN_VIEW</span><span style="color:#E1E4E8">)</span></span>
|
|
63
|
+
<span class="line"><span style="color:#E1E4E8">object2.renderMask.</span><span style="color:#B392F0">clear</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">on</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">MAIN_VIEW</span><span style="color:#E1E4E8">)</span></span>
|
|
64
|
+
<span class="line"><span style="color:#E1E4E8">camera1.renderMask.</span><span style="color:#B392F0">clear</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">on</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">OFFSCREEN_VIEW</span><span style="color:#E1E4E8">)</span></span>
|
|
65
|
+
<span class="line"><span style="color:#E1E4E8">camera2.renderMask.</span><span style="color:#B392F0">clear</span><span style="color:#E1E4E8">().</span><span style="color:#B392F0">on</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">MAIN_VIEW</span><span style="color:#E1E4E8">)</span></span>
|
|
66
|
+
<span class="line"></span>
|
|
67
|
+
<span class="line"><span style="color:#6A737D">//set up the cameras</span></span>
|
|
68
|
+
<span class="line"><span style="color:#E1E4E8">camera1.far </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 500</span></span>
|
|
69
|
+
<span class="line"><span style="color:#E1E4E8">camera1.transform.position.z </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 5</span></span>
|
|
70
|
+
<span class="line"><span style="color:#E1E4E8">camera2.transform.position.z </span><span style="color:#F97583">=</span><span style="color:#79B8FF"> 1</span></span>
|
|
71
|
+
<span class="line"></span>
|
|
72
|
+
<span class="line"><span style="color:#F97583">if</span><span style="color:#E1E4E8"> (</span></span>
|
|
73
|
+
<span class="line"><span style="color:#E1E4E8"> camera1.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#F97583"> &&</span></span>
|
|
74
|
+
<span class="line"><span style="color:#E1E4E8"> camera2.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span></span>
|
|
75
|
+
<span class="line"><span style="color:#E1E4E8">) {</span></span>
|
|
76
|
+
<span class="line"><span style="color:#E1E4E8"> camera1.projection.fov </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 180</span><span style="color:#F97583"> *</span><span style="color:#79B8FF"> 60</span></span>
|
|
77
|
+
<span class="line"><span style="color:#E1E4E8"> camera2.projection.fov </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 180</span><span style="color:#F97583"> *</span><span style="color:#79B8FF"> 60</span></span>
|
|
78
|
+
<span class="line"><span style="color:#E1E4E8">}</span></span>
|
|
79
|
+
<span class="line"></span>
|
|
80
|
+
<span class="line"><span style="color:#E1E4E8">document.body.</span><span style="color:#B392F0">append</span><span style="color:#E1E4E8">(canvas)</span></span>
|
|
81
|
+
<span class="line"><span style="color:#B392F0">updateView</span><span style="color:#E1E4E8">()</span></span>
|
|
82
|
+
<span class="line"><span style="color:#B392F0">addEventListener</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'resize'</span><span style="color:#E1E4E8">, updateView)</span></span>
|
|
83
|
+
<span class="line"><span style="color:#B392F0">requestAnimationFrame</span><span style="color:#E1E4E8">(update)</span></span>
|
|
84
|
+
<span class="line"></span>
|
|
85
|
+
<span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> update</span><span style="color:#E1E4E8">() {</span></span>
|
|
86
|
+
<span class="line"><span style="color:#E1E4E8"> stats.</span><span style="color:#B392F0">begin</span><span style="color:#E1E4E8">()</span></span>
|
|
87
|
+
<span class="line"><span style="color:#E1E4E8"> renderer.</span><span style="color:#B392F0">render</span><span style="color:#E1E4E8">([object1, object2, camera1, camera2], renderDevice)</span></span>
|
|
88
|
+
<span class="line"></span>
|
|
89
|
+
<span class="line"><span style="color:#E1E4E8"> object1.transform.orientation.</span><span style="color:#B392F0">multiply</span><span style="color:#E1E4E8">(</span></span>
|
|
90
|
+
<span class="line"><span style="color:#E1E4E8"> Quaternion.</span><span style="color:#B392F0">fromEuler</span><span style="color:#E1E4E8">(Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 1000</span><span style="color:#E1E4E8">, Math.</span><span style="color:#79B8FF">PI</span><span style="color:#F97583"> /</span><span style="color:#79B8FF"> 1000</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0</span><span style="color:#E1E4E8">)</span></span>
|
|
91
|
+
<span class="line"><span style="color:#E1E4E8"> )</span></span>
|
|
92
|
+
<span class="line"><span style="color:#E1E4E8"> stats.</span><span style="color:#B392F0">end</span><span style="color:#E1E4E8">()</span></span>
|
|
93
|
+
<span class="line"></span>
|
|
94
|
+
<span class="line"><span style="color:#B392F0"> requestAnimationFrame</span><span style="color:#E1E4E8">(update)</span></span>
|
|
95
|
+
<span class="line"><span style="color:#E1E4E8">}</span></span>
|
|
96
|
+
<span class="line"></span>
|
|
97
|
+
<span class="line"><span style="color:#F97583">function</span><span style="color:#B392F0"> updateView</span><span style="color:#E1E4E8">() {</span></span>
|
|
98
|
+
<span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> fullWidth</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> devicePixelRatio</span></span>
|
|
99
|
+
<span class="line"><span style="color:#F97583"> const</span><span style="color:#79B8FF"> fullHeight</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> innerHeight </span><span style="color:#F97583">*</span><span style="color:#E1E4E8"> devicePixelRatio</span></span>
|
|
100
|
+
<span class="line"></span>
|
|
101
|
+
<span class="line"><span style="color:#E1E4E8"> canvas.style.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerWidth </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span></span>
|
|
102
|
+
<span class="line"><span style="color:#E1E4E8"> canvas.style.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> innerHeight </span><span style="color:#F97583">+</span><span style="color:#9ECBFF"> "px"</span></span>
|
|
103
|
+
<span class="line"><span style="color:#E1E4E8"> canvas.width </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> fullWidth</span></span>
|
|
104
|
+
<span class="line"><span style="color:#E1E4E8"> canvas.height </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> fullHeight</span></span>
|
|
105
|
+
<span class="line"></span>
|
|
106
|
+
<span class="line"><span style="color:#F97583"> if</span><span style="color:#E1E4E8"> (</span></span>
|
|
107
|
+
<span class="line"><span style="color:#E1E4E8"> camera1.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span><span style="color:#F97583"> &&</span></span>
|
|
108
|
+
<span class="line"><span style="color:#E1E4E8"> camera2.projection </span><span style="color:#F97583">instanceof</span><span style="color:#B392F0"> PerspectiveProjection</span></span>
|
|
109
|
+
<span class="line"><span style="color:#E1E4E8"> ) {</span></span>
|
|
110
|
+
<span class="line"><span style="color:#E1E4E8"> camera1.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> fullWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> fullHeight</span></span>
|
|
111
|
+
<span class="line"><span style="color:#E1E4E8"> camera2.projection.aspect </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> fullWidth </span><span style="color:#F97583">/</span><span style="color:#E1E4E8"> fullHeight</span></span>
|
|
112
|
+
<span class="line"><span style="color:#E1E4E8"> }</span></span>
|
|
113
|
+
<span class="line"><span style="color:#E1E4E8">}</span></span>
|
|
114
|
+
<span class="line"></span>
|
|
115
|
+
<span class="line"><span style="color:#6A737D">// demo-only GUI controls</span></span>
|
|
116
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> controls</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> GUI</span><span style="color:#E1E4E8">()</span></span>
|
|
117
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> buildOptionsFolder</span><span style="color:#F97583"> =</span><span style="color:#E1E4E8"> controls.</span><span style="color:#B392F0">addFolder</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Settings"</span><span style="color:#E1E4E8">)</span></span>
|
|
118
|
+
<span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
|
|
119
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(camera1.transform.position, </span><span style="color:#9ECBFF">'z'</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">10</span><span style="color:#E1E4E8">)</span></span>
|
|
120
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Position Z"</span><span style="color:#E1E4E8">)</span></span>
|
|
121
|
+
<span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
|
|
122
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(camera1, </span><span style="color:#9ECBFF">'near'</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">0.1</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">10</span><span style="color:#E1E4E8">)</span></span>
|
|
123
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Camera Near"</span><span style="color:#E1E4E8">)</span></span>
|
|
124
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onChange</span><span style="color:#E1E4E8">((</span><span style="color:#FFAB70">value</span><span style="color:#E1E4E8">)</span><span style="color:#F97583">=></span><span style="color:#E1E4E8">depthMaterial.near </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> value)</span></span>
|
|
125
|
+
<span class="line"><span style="color:#E1E4E8">buildOptionsFolder</span></span>
|
|
126
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(camera1, </span><span style="color:#9ECBFF">'far'</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">10</span><span style="color:#E1E4E8">, </span><span style="color:#79B8FF">500</span><span style="color:#E1E4E8">)</span></span>
|
|
127
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">name</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">"Camera Far"</span><span style="color:#E1E4E8">)</span></span>
|
|
128
|
+
<span class="line"><span style="color:#E1E4E8"> .</span><span style="color:#B392F0">onChange</span><span style="color:#E1E4E8">((</span><span style="color:#FFAB70">value</span><span style="color:#E1E4E8">)</span><span style="color:#F97583">=></span><span style="color:#E1E4E8">depthMaterial.far </span><span style="color:#F97583">=</span><span style="color:#E1E4E8"> value)</span></span>
|
|
129
|
+
<span class="line"><span style="color:#E1E4E8">buildOptionsFolder.</span><span style="color:#B392F0">open</span><span style="color:#E1E4E8">()</span></span>
|
|
130
|
+
<span class="line"><span style="color:#B392F0">addRenderGraphGuiAddon</span><span style="color:#E1E4E8">({</span></span>
|
|
131
|
+
<span class="line"><span style="color:#E1E4E8"> gui: controls,</span></span>
|
|
132
|
+
<span class="line"><span style="color:#E1E4E8"> renderer</span></span>
|
|
133
|
+
<span class="line"><span style="color:#E1E4E8">})</span></span>
|
|
134
|
+
<span class="line"></span>
|
|
135
|
+
<span class="line"><span style="color:#6A737D">// demo-only performance monitor</span></span>
|
|
136
|
+
<span class="line"><span style="color:#F97583">const</span><span style="color:#79B8FF"> stats</span><span style="color:#F97583"> =</span><span style="color:#F97583"> new</span><span style="color:#B392F0"> Stats</span><span style="color:#E1E4E8">()</span></span>
|
|
137
|
+
<span class="line"><span style="color:#E1E4E8">stats.</span><span style="color:#B392F0">showPanel</span><span style="color:#E1E4E8">(</span><span style="color:#79B8FF">1</span><span style="color:#E1E4E8">)</span></span>
|
|
138
|
+
<span class="line"><span style="color:#E1E4E8">document.body.</span><span style="color:#B392F0">append</span><span style="color:#E1E4E8">(stats.dom)</span></span>
|
|
139
|
+
<span class="line"><span style="color:#E1E4E8">stats.dom.</span><span style="color:#B392F0">removeAttribute</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'style'</span><span style="color:#E1E4E8">)</span></span>
|
|
140
|
+
<span class="line"><span style="color:#E1E4E8">stats.dom.classList.</span><span style="color:#B392F0">add</span><span style="color:#E1E4E8">(</span><span style="color:#9ECBFF">'performance-monitor'</span><span style="color:#E1E4E8">)</span></span></code></pre> </div> </main> </div> <script type="module">var e=document.getElementById(`menu-toggle`);e?.addEventListener(`click`,()=>{let t=document.body.classList.toggle(`menu-open`);e.setAttribute(`aria-expanded`,t?`true`:`false`)});var t=document.getElementById(`site-sidebar`);if(t instanceof HTMLElement){let e=window.location.pathname.replace(/\/+$/,``)||`/`,n=`sidebar-scroll:${e===`/`?`/`:e.split(`/`)[1]||e}`,r=0,i=()=>{try{let e=sessionStorage.getItem(n);return e===null?null:Number.parseInt(e,10)}catch{return null}},a=()=>{try{sessionStorage.setItem(n,String(t.scrollTop))}catch{}r=0},o=()=>{r===0&&(r=window.requestAnimationFrame(a))},s=i();s!==null&&Number.isFinite(s)&&(t.scrollTop=s),t.addEventListener(`scroll`,o,{passive:!0}),window.addEventListener(`pagehide`,a),window.addEventListener(`beforeunload`,a)}</script></body> </html>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Image Target</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: dark;
|
|
10
|
+
--bg: #05070a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
html,
|
|
14
|
+
body {
|
|
15
|
+
margin: 0;
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
background: var(--bg);
|
|
19
|
+
color: #eef2f7;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
canvas {
|
|
24
|
+
background-color: black;
|
|
25
|
+
touch-action: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.dg.ac {
|
|
29
|
+
position: fixed;
|
|
30
|
+
top: 0;
|
|
31
|
+
left: auto;
|
|
32
|
+
right: 0;
|
|
33
|
+
z-index: 10000;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.performance-monitor {
|
|
37
|
+
position: fixed;
|
|
38
|
+
top: 0%;
|
|
39
|
+
left: 0%;
|
|
40
|
+
right: auto;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
opacity: 0.9;
|
|
43
|
+
z-index: 10000;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
<script type="importmap">{"imports":{"chorama":"https://cdn.jsdelivr.net/npm/chorama@0.1.1/dist/index.module.js","@rollup/plugin-node-resolve":"https://cdn.jsdelivr.net/npm/@rollup/plugin-node-resolve@16.0.3/dist/es/index.js","@rollup/plugin-typescript":"https://cdn.jsdelivr.net/npm/@rollup/plugin-typescript@12.3.0/dist/es/index.js","astro":"https://cdn.jsdelivr.net/npm/astro@7.2.2/dist/index.js","dat.gui":"https://cdn.jsdelivr.net/npm/dat.gui@0.7.9/build/dat.gui.module.js","hash-it":"https://cdn.jsdelivr.net/npm/hash-it@7.0.2/dist/es/index.mjs","hisabati":"https://cdn.jsdelivr.net/npm/hisabati@0.1.0/dist/index.module.js","marangi":"https://cdn.jsdelivr.net/npm/marangi@0.1.0/dist/index.module.js","rollup":"https://cdn.jsdelivr.net/npm/rollup@4.62.5/dist/es/rollup.js","stats.js":"https://cdn.jsdelivr.net/npm/stats.js@0.17.0/src/Stats.js","vifaa":"https://cdn.jsdelivr.net/npm/vifaa@0.3.0/dist/index.module.js","vite":"https://cdn.jsdelivr.net/npm/vite@8.2.1/dist/node/index.js","wima-docs-website-template":"https://cdn.jsdelivr.net/npm/wima-docs-website-template@0.1.0/src/index.js"}}</script>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
<script type="module">import Stats from "stats.js";
|
|
50
|
+
import {
|
|
51
|
+
MeshMaterial3D,
|
|
52
|
+
BasicMaterial,
|
|
53
|
+
Quaternion,
|
|
54
|
+
WebGLRenderer,
|
|
55
|
+
TextureLoader,
|
|
56
|
+
PerspectiveProjection,
|
|
57
|
+
Camera,
|
|
58
|
+
WebGLRenderDevice,
|
|
59
|
+
TextureType,
|
|
60
|
+
SkyBox,
|
|
61
|
+
Texture,
|
|
62
|
+
TextureFormat,
|
|
63
|
+
ImageRenderTarget,
|
|
64
|
+
Color,
|
|
65
|
+
CuboidMeshBuilder,
|
|
66
|
+
MeshMaterialPlugin,
|
|
67
|
+
CanvasTarget,
|
|
68
|
+
SkyboxPlugin,
|
|
69
|
+
CameraPlugin
|
|
70
|
+
} from "chorama"
|
|
71
|
+
|
|
72
|
+
const canvas = document.createElement('canvas')
|
|
73
|
+
const canvasTarget = new CanvasTarget(canvas)
|
|
74
|
+
const renderDevice = new WebGLRenderDevice(canvas,{
|
|
75
|
+
depth:true
|
|
76
|
+
})
|
|
77
|
+
const renderer = new WebGLRenderer({
|
|
78
|
+
plugins:[
|
|
79
|
+
new CameraPlugin(),
|
|
80
|
+
new SkyboxPlugin(),
|
|
81
|
+
new MeshMaterialPlugin(),
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const renderTarget = new ImageRenderTarget({
|
|
86
|
+
width:1024,
|
|
87
|
+
height:1024,
|
|
88
|
+
color:[
|
|
89
|
+
new Texture({
|
|
90
|
+
type:TextureType.Texture2D,
|
|
91
|
+
format:TextureFormat.RGBA8Unorm
|
|
92
|
+
})
|
|
93
|
+
],
|
|
94
|
+
internalDepthStencil:TextureFormat.Depth24PlusStencil8
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const camera1 = new Camera(renderTarget)
|
|
98
|
+
const camera2 = new Camera(canvasTarget)
|
|
99
|
+
const OFFSCREEN_VIEW = 0
|
|
100
|
+
const MAIN_VIEW = 1
|
|
101
|
+
|
|
102
|
+
const textureLoader = new TextureLoader()
|
|
103
|
+
const texture = textureLoader.load({
|
|
104
|
+
paths: ["/images/uv.jpg"],
|
|
105
|
+
flipY: true
|
|
106
|
+
})
|
|
107
|
+
const day = textureLoader.load({
|
|
108
|
+
paths: [
|
|
109
|
+
"/images/skybox/miramar_right.png",
|
|
110
|
+
"/images/skybox/miramar_left.png",
|
|
111
|
+
"/images/skybox/miramar_top.png",
|
|
112
|
+
"/images/skybox/miramar_bottom.png",
|
|
113
|
+
"/images/skybox/miramar_back.png",
|
|
114
|
+
"/images/skybox/miramar_front.png"
|
|
115
|
+
],
|
|
116
|
+
type: TextureType.TextureCubeMap
|
|
117
|
+
})
|
|
118
|
+
const mesh = new CuboidMeshBuilder().build()
|
|
119
|
+
const object1 = new MeshMaterial3D(mesh, new BasicMaterial({
|
|
120
|
+
mainTexture: texture
|
|
121
|
+
}))
|
|
122
|
+
const object2 = new MeshMaterial3D(mesh, new BasicMaterial({
|
|
123
|
+
mainTexture: renderTarget.color[0]
|
|
124
|
+
}))
|
|
125
|
+
const skyBox = new SkyBox({
|
|
126
|
+
day,
|
|
127
|
+
night:day
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
object1.renderMask.clear().on(OFFSCREEN_VIEW)
|
|
131
|
+
object2.renderMask.clear().on(MAIN_VIEW)
|
|
132
|
+
skyBox.renderMask.clear().on(MAIN_VIEW)
|
|
133
|
+
camera1.renderMask.clear().on(OFFSCREEN_VIEW)
|
|
134
|
+
camera2.renderMask.clear().on(MAIN_VIEW)
|
|
135
|
+
|
|
136
|
+
//set up the cameras
|
|
137
|
+
renderTarget.clearColor = Color.CYAN.clone()
|
|
138
|
+
camera1.target = renderTarget
|
|
139
|
+
camera1.transform.position.z = 5
|
|
140
|
+
camera2.transform.position.z = 5
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
camera1.projection instanceof PerspectiveProjection &&
|
|
144
|
+
camera2.projection instanceof PerspectiveProjection
|
|
145
|
+
) {
|
|
146
|
+
camera1.projection.fov = Math.PI / 180 * 60
|
|
147
|
+
camera2.projection.fov = Math.PI / 180 * 60
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
document.body.append(canvas)
|
|
151
|
+
updateView()
|
|
152
|
+
addEventListener('resize', updateView)
|
|
153
|
+
requestAnimationFrame(update)
|
|
154
|
+
|
|
155
|
+
function update() {
|
|
156
|
+
stats.begin()
|
|
157
|
+
renderer.render([object1, skyBox, object2, camera1, camera2], renderDevice)
|
|
158
|
+
|
|
159
|
+
object1.transform.orientation.multiply(
|
|
160
|
+
Quaternion.fromEuler(Math.PI / 1000, Math.PI / 1000, 0)
|
|
161
|
+
)
|
|
162
|
+
object2.transform.orientation.multiply(
|
|
163
|
+
Quaternion.fromEuler(Math.PI / 1000, Math.PI / 1000, 0)
|
|
164
|
+
)
|
|
165
|
+
stats.end()
|
|
166
|
+
|
|
167
|
+
requestAnimationFrame(update)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function updateView() {
|
|
171
|
+
const fullWidth = innerWidth * devicePixelRatio
|
|
172
|
+
const fullHeight = innerHeight * devicePixelRatio
|
|
173
|
+
|
|
174
|
+
canvas.style.width = innerWidth + "px"
|
|
175
|
+
canvas.style.height = innerHeight + "px"
|
|
176
|
+
canvas.width = fullWidth
|
|
177
|
+
canvas.height = fullHeight
|
|
178
|
+
|
|
179
|
+
if (
|
|
180
|
+
camera1.projection instanceof PerspectiveProjection &&
|
|
181
|
+
camera2.projection instanceof PerspectiveProjection
|
|
182
|
+
) {
|
|
183
|
+
camera1.projection.aspect = fullWidth / fullHeight
|
|
184
|
+
camera2.projection.aspect = fullWidth / fullHeight
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// demo-only performance monitor
|
|
189
|
+
const stats = new Stats()
|
|
190
|
+
stats.showPanel(1)
|
|
191
|
+
document.body.append(stats.dom)
|
|
192
|
+
stats.dom.removeAttribute('style')
|
|
193
|
+
stats.dom.classList.add('performance-monitor')
|
|
194
|
+
</script>
|
|
195
|
+
</body>
|
|
196
|
+
</html>
|