@tolokoban/tgd 2.0.0 → 2.0.3
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/lib/dist/buffer/buffer.d.ts +0 -0
- package/lib/dist/buffer/buffer.d.ts.map +0 -0
- package/lib/dist/buffer/buffer.js +37 -0
- package/lib/dist/buffer/index.d.ts +0 -0
- package/lib/dist/buffer/index.d.ts.map +0 -0
- package/lib/dist/buffer/index.js +2 -0
- package/lib/dist/camera/camera-orthographic.d.ts +14 -12
- package/lib/dist/camera/camera-orthographic.d.ts.map +1 -1
- package/lib/dist/camera/camera-orthographic.js +97 -0
- package/lib/dist/camera/camera-perspective.d.ts +20 -16
- package/lib/dist/camera/camera-perspective.d.ts.map +1 -1
- package/lib/dist/camera/camera-perspective.js +94 -0
- package/lib/dist/camera/camera.d.ts +95 -18
- package/lib/dist/camera/camera.d.ts.map +1 -1
- package/lib/dist/camera/camera.js +368 -0
- package/lib/dist/camera/index.d.ts +3 -3
- package/lib/dist/camera/index.d.ts.map +1 -1
- package/lib/dist/camera/index.js +4 -0
- package/lib/dist/canvas/gizmo/gizmo.d.ts +42 -0
- package/lib/dist/canvas/gizmo/gizmo.d.ts.map +1 -0
- package/lib/dist/canvas/gizmo/gizmo.js +183 -0
- package/lib/dist/canvas/gizmo/index.d.ts +2 -0
- package/lib/dist/canvas/gizmo/index.d.ts.map +1 -0
- package/lib/dist/canvas/gizmo/index.js +2 -0
- package/lib/dist/canvas/gizmo/painter/shader.frag +17 -0
- package/lib/dist/canvas/gizmo/painter/shader.vert +24 -0
- package/lib/dist/canvas/gizmo/painter/tips.d.ts +13 -0
- package/lib/dist/canvas/gizmo/painter/tips.d.ts.map +1 -0
- package/lib/dist/canvas/gizmo/painter/tips.js +96 -0
- package/lib/dist/canvas/index.d.ts +3 -0
- package/lib/dist/canvas/index.d.ts.map +1 -0
- package/lib/dist/canvas/index.js +3 -0
- package/lib/dist/canvas/landscape/index.d.ts +2 -0
- package/lib/dist/canvas/landscape/index.d.ts.map +1 -0
- package/lib/dist/canvas/landscape/index.js +2 -0
- package/lib/dist/canvas/landscape/landscape.d.ts +18 -0
- package/lib/dist/canvas/landscape/landscape.d.ts.map +1 -0
- package/lib/dist/canvas/landscape/landscape.js +40 -0
- package/lib/dist/color/color.d.ts +22 -0
- package/lib/dist/color/color.d.ts.map +1 -0
- package/lib/dist/color/color.js +160 -0
- package/lib/dist/color/index.d.ts +2 -0
- package/lib/dist/color/index.d.ts.map +1 -0
- package/lib/dist/color/index.js +2 -0
- package/lib/dist/context/animation/animation-manager.d.ts +8 -0
- package/lib/dist/context/animation/animation-manager.d.ts.map +1 -0
- package/lib/dist/context/animation/animation-manager.js +41 -0
- package/lib/dist/context/context.d.ts +111 -12
- package/lib/dist/context/context.d.ts.map +1 -1
- package/lib/dist/context/context.js +297 -0
- package/lib/dist/context/index.d.ts +0 -0
- package/lib/dist/context/index.d.ts.map +0 -0
- package/lib/dist/context/index.js +2 -0
- package/lib/dist/controller/camera/index.d.ts +0 -0
- package/lib/dist/controller/camera/index.d.ts.map +0 -0
- package/lib/dist/controller/camera/index.js +2 -0
- package/lib/dist/controller/camera/orbit.d.ts +88 -8
- package/lib/dist/controller/camera/orbit.d.ts.map +1 -1
- package/lib/dist/controller/camera/orbit.js +186 -0
- package/lib/dist/controller/index.d.ts +0 -0
- package/lib/dist/controller/index.d.ts.map +0 -0
- package/lib/dist/controller/index.js +2 -0
- package/lib/dist/dataset/dataset.d.ts +80 -11
- package/lib/dist/dataset/dataset.d.ts.map +1 -1
- package/lib/dist/dataset/dataset.js +217 -0
- package/lib/dist/dataset/index.d.ts +0 -0
- package/lib/dist/dataset/index.d.ts.map +0 -0
- package/lib/dist/dataset/index.js +2 -0
- package/lib/dist/debug.d.ts +0 -0
- package/lib/dist/debug.d.ts.map +0 -0
- package/lib/dist/debug.js +13 -0
- package/lib/dist/event/event.d.ts +0 -0
- package/lib/dist/event/event.d.ts.map +0 -0
- package/lib/dist/event/event.js +13 -0
- package/lib/dist/event/index.d.ts +2 -0
- package/lib/dist/event/index.d.ts.map +1 -0
- package/lib/dist/event/index.js +2 -0
- package/lib/dist/filter/blur.d.ts +10 -0
- package/lib/dist/filter/blur.d.ts.map +1 -0
- package/lib/dist/filter/blur.js +42 -0
- package/lib/dist/filter/filter.d.ts +39 -0
- package/lib/dist/filter/filter.d.ts.map +1 -0
- package/lib/dist/filter/filter.js +43 -0
- package/lib/dist/filter/hue-rotation.d.ts +12 -0
- package/lib/dist/filter/hue-rotation.d.ts.map +1 -0
- package/lib/dist/filter/hue-rotation.js +41 -0
- package/lib/dist/filter/index.d.ts +4 -0
- package/lib/dist/filter/index.d.ts.map +1 -0
- package/lib/dist/filter/index.js +4 -0
- package/lib/dist/geometry/box.d.ts +10 -0
- package/lib/dist/geometry/box.d.ts.map +1 -0
- package/lib/dist/geometry/box.js +136 -0
- package/lib/dist/geometry/geometry.d.ts +47 -0
- package/lib/dist/geometry/geometry.d.ts.map +1 -0
- package/lib/dist/geometry/geometry.js +190 -0
- package/lib/dist/geometry/index.d.ts +3 -0
- package/lib/dist/geometry/index.d.ts.map +1 -0
- package/lib/dist/geometry/index.js +3 -0
- package/lib/dist/index.d.ts +9 -0
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +21 -1
- package/lib/dist/input/index.d.ts +2 -0
- package/lib/dist/input/index.d.ts.map +1 -1
- package/lib/dist/input/index.js +4 -0
- package/lib/dist/input/inputs.d.ts +11 -0
- package/lib/dist/input/inputs.d.ts.map +1 -0
- package/lib/dist/input/inputs.js +23 -0
- package/lib/dist/input/keyboard.d.ts +6 -2
- package/lib/dist/input/keyboard.d.ts.map +1 -1
- package/lib/dist/input/keyboard.js +46 -0
- package/lib/dist/input/pointer.d.ts +24 -40
- package/lib/dist/input/pointer.d.ts.map +1 -1
- package/lib/dist/input/pointer.js +138 -0
- package/lib/dist/light/index.d.ts +2 -0
- package/lib/dist/light/index.d.ts.map +1 -0
- package/lib/dist/light/index.js +2 -0
- package/lib/dist/light/light.d.ts +16 -0
- package/lib/dist/light/light.d.ts.map +1 -0
- package/lib/dist/light/light.js +19 -0
- package/lib/dist/loader/image.d.ts +4 -0
- package/lib/dist/loader/image.d.ts.map +1 -1
- package/lib/dist/loader/image.js +31 -0
- package/lib/dist/loader/index.d.ts +0 -0
- package/lib/dist/loader/index.d.ts.map +0 -0
- package/lib/dist/loader/index.js +2 -0
- package/lib/dist/material/diffuse.d.ts +28 -0
- package/lib/dist/material/diffuse.d.ts.map +1 -0
- package/lib/dist/material/diffuse.js +68 -0
- package/lib/dist/material/ghost.d.ts +19 -0
- package/lib/dist/material/ghost.d.ts.map +1 -0
- package/lib/dist/material/ghost.js +25 -0
- package/lib/dist/material/index.d.ts +5 -0
- package/lib/dist/material/index.d.ts.map +1 -0
- package/lib/dist/material/index.js +5 -0
- package/lib/dist/material/material.d.ts +29 -0
- package/lib/dist/material/material.d.ts.map +1 -0
- package/lib/dist/material/material.js +14 -0
- package/lib/dist/material/normals.d.ts +13 -0
- package/lib/dist/material/normals.d.ts.map +1 -0
- package/lib/dist/material/normals.js +20 -0
- package/lib/dist/math/index.d.ts +3 -0
- package/lib/dist/math/index.d.ts.map +1 -1
- package/lib/dist/math/index.js +8 -0
- package/lib/dist/math/mat3.d.ts +8 -0
- package/lib/dist/math/mat3.d.ts.map +1 -1
- package/lib/dist/math/mat3.js +154 -0
- package/lib/dist/math/mat4.d.ts +111 -2
- package/lib/dist/math/mat4.d.ts.map +1 -1
- package/lib/dist/math/mat4.js +402 -0
- package/lib/dist/math/mat4.test.d.ts +0 -0
- package/lib/dist/math/mat4.test.d.ts.map +0 -0
- package/lib/dist/math/mat4.test.js +57 -0
- package/lib/dist/math/quat.d.ts +1 -0
- package/lib/dist/math/quat.d.ts.map +1 -1
- package/lib/dist/math/quat.js +184 -0
- package/lib/dist/math/quat.test.d.ts +0 -0
- package/lib/dist/math/quat.test.d.ts.map +0 -0
- package/lib/dist/math/quat.test.js +45 -0
- package/lib/dist/math/transfo.d.ts +27 -0
- package/lib/dist/math/transfo.d.ts.map +1 -0
- package/lib/dist/math/transfo.js +86 -0
- package/lib/dist/math/vec2.d.ts +34 -0
- package/lib/dist/math/vec2.d.ts.map +1 -0
- package/lib/dist/math/vec2.js +119 -0
- package/lib/dist/math/vec3.d.ts +26 -12
- package/lib/dist/math/vec3.d.ts.map +1 -1
- package/lib/dist/math/vec3.js +187 -0
- package/lib/dist/math/vec3.test.d.ts +2 -0
- package/lib/dist/math/vec3.test.d.ts.map +1 -0
- package/lib/dist/math/vec3.test.js +22 -0
- package/lib/dist/math/vec4.d.ts +8 -4
- package/lib/dist/math/vec4.d.ts.map +1 -1
- package/lib/dist/math/vec4.js +152 -0
- package/lib/dist/math/vec4.test.d.ts +0 -0
- package/lib/dist/math/vec4.test.d.ts.map +0 -0
- package/lib/dist/math/vec4.test.js +15 -0
- package/lib/dist/painter/axis/axis.d.ts +26 -0
- package/lib/dist/painter/axis/axis.d.ts.map +1 -0
- package/lib/dist/painter/axis/axis.frag +11 -0
- package/lib/dist/painter/axis/axis.js +84 -0
- package/lib/dist/painter/axis/axis.vert +21 -0
- package/lib/dist/painter/axis/index.d.ts +2 -0
- package/lib/dist/painter/axis/index.d.ts.map +1 -0
- package/lib/dist/painter/axis/index.js +2 -0
- package/lib/dist/painter/background/background.d.ts +11 -8
- package/lib/dist/painter/background/background.d.ts.map +1 -1
- package/lib/dist/painter/background/background.frag +11 -0
- package/lib/dist/painter/background/background.js +63 -0
- package/lib/dist/painter/background/background.vert +16 -0
- package/lib/dist/painter/background/index.d.ts +0 -0
- package/lib/dist/painter/background/index.d.ts.map +0 -0
- package/lib/dist/painter/background/index.js +2 -0
- package/lib/dist/painter/clear.d.ts +15 -10
- package/lib/dist/painter/clear.d.ts.map +1 -1
- package/lib/dist/painter/clear.js +51 -0
- package/lib/dist/painter/depth.d.ts +22 -0
- package/lib/dist/painter/depth.d.ts.map +1 -0
- package/lib/dist/painter/depth.js +34 -0
- package/lib/dist/painter/filter/filter.d.ts +23 -0
- package/lib/dist/painter/filter/filter.d.ts.map +1 -0
- package/lib/dist/painter/filter/filter.frag +15 -0
- package/lib/dist/painter/filter/filter.js +76 -0
- package/lib/dist/painter/filter/filter.vert +11 -0
- package/lib/dist/painter/filter/index.d.ts +2 -0
- package/lib/dist/painter/filter/index.d.ts.map +1 -0
- package/lib/dist/painter/filter/index.js +2 -0
- package/lib/dist/painter/framebuffer.d.ts +38 -0
- package/lib/dist/painter/framebuffer.d.ts.map +1 -0
- package/lib/dist/painter/framebuffer.js +102 -0
- package/lib/dist/painter/group.d.ts +16 -4
- package/lib/dist/painter/group.d.ts.map +1 -1
- package/lib/dist/painter/group.js +59 -0
- package/lib/dist/painter/index.d.ts +10 -5
- package/lib/dist/painter/index.d.ts.map +1 -1
- package/lib/dist/painter/index.js +12 -0
- package/lib/dist/painter/logic.d.ts +4 -2
- package/lib/dist/painter/logic.d.ts.map +1 -1
- package/lib/dist/painter/logic.js +16 -0
- package/lib/dist/painter/mesh/gltf/gltf.d.ts +14 -0
- package/lib/dist/painter/mesh/gltf/gltf.d.ts.map +1 -0
- package/lib/dist/painter/mesh/gltf/gltf.js +93 -0
- package/lib/dist/painter/mesh/gltf/index.d.ts +2 -0
- package/lib/dist/painter/mesh/gltf/index.d.ts.map +1 -0
- package/lib/dist/painter/mesh/gltf/index.js +2 -0
- package/lib/dist/painter/mesh/index.d.ts +4 -0
- package/lib/dist/painter/mesh/index.d.ts.map +1 -0
- package/lib/dist/painter/mesh/index.js +4 -0
- package/lib/dist/painter/mesh/mesh/index.d.ts +2 -0
- package/lib/dist/painter/mesh/mesh/index.d.ts.map +1 -0
- package/lib/dist/painter/mesh/mesh/index.js +2 -0
- package/lib/dist/painter/mesh/mesh/mesh.d.ts +32 -0
- package/lib/dist/painter/mesh/mesh/mesh.d.ts.map +1 -0
- package/lib/dist/painter/mesh/mesh/mesh.js +128 -0
- package/lib/dist/painter/mesh/normals/index.d.ts +2 -0
- package/lib/dist/painter/mesh/normals/index.d.ts.map +1 -0
- package/lib/dist/painter/mesh/normals/index.js +2 -0
- package/lib/dist/painter/mesh/normals/normals.d.ts +18 -0
- package/lib/dist/painter/mesh/normals/normals.d.ts.map +1 -0
- package/lib/dist/painter/mesh/normals/normals.js +53 -0
- package/lib/dist/painter/mesh/normals/shader.frag +14 -0
- package/lib/dist/painter/mesh/normals/shader.vert +18 -0
- package/lib/dist/painter/node.d.ts +26 -0
- package/lib/dist/painter/node.d.ts.map +1 -0
- package/lib/dist/painter/node.js +67 -0
- package/lib/dist/painter/painter.d.ts +1 -1
- package/lib/dist/painter/painter.d.ts.map +1 -1
- package/lib/dist/painter/painter.js +4 -0
- package/lib/dist/painter/segments/index.d.ts +2 -0
- package/lib/dist/painter/segments/index.d.ts.map +1 -0
- package/lib/dist/painter/segments/index.js +2 -0
- package/lib/dist/painter/segments/segments.d.ts +85 -0
- package/lib/dist/painter/segments/segments.d.ts.map +1 -0
- package/lib/dist/painter/segments/segments.frag +12 -0
- package/lib/dist/painter/segments/segments.js +196 -0
- package/lib/dist/painter/segments/segments.vert +114 -0
- package/lib/dist/painter/skybox/index.d.ts +0 -0
- package/lib/dist/painter/skybox/index.d.ts.map +0 -0
- package/lib/dist/painter/skybox/index.js +2 -0
- package/lib/dist/painter/skybox/skybox.d.ts +11 -17
- package/lib/dist/painter/skybox/skybox.d.ts.map +1 -1
- package/lib/dist/painter/skybox/skybox.frag +15 -0
- package/lib/dist/painter/skybox/skybox.js +59 -0
- package/lib/dist/painter/skybox/skybox.vert +10 -0
- package/lib/dist/parser/for-each-line.d.ts +3 -0
- package/lib/dist/parser/for-each-line.d.ts.map +1 -1
- package/lib/dist/parser/for-each-line.js +17 -0
- package/lib/dist/parser/gltf/gltf.d.ts +34 -0
- package/lib/dist/parser/gltf/gltf.d.ts.map +1 -0
- package/lib/dist/parser/gltf/gltf.js +164 -0
- package/lib/dist/parser/gltf/index.d.ts +2 -0
- package/lib/dist/parser/gltf/index.d.ts.map +1 -0
- package/lib/dist/parser/gltf/index.js +2 -0
- package/lib/dist/parser/gltf/parser.d.ts +9 -0
- package/lib/dist/parser/gltf/parser.d.ts.map +1 -0
- package/lib/dist/parser/gltf/parser.js +53 -0
- package/lib/dist/parser/index.d.ts +1 -0
- package/lib/dist/parser/index.d.ts.map +1 -1
- package/lib/dist/parser/index.js +3 -0
- package/lib/dist/parser/mesh/wavefront.d.ts +70 -12
- package/lib/dist/parser/mesh/wavefront.d.ts.map +1 -1
- package/lib/dist/parser/mesh/wavefront.js +246 -0
- package/lib/dist/program/index.d.ts +0 -0
- package/lib/dist/program/index.d.ts.map +0 -0
- package/lib/dist/program/index.js +2 -0
- package/lib/dist/program/program.d.ts +17 -2
- package/lib/dist/program/program.d.ts.map +1 -1
- package/lib/dist/program/program.js +220 -0
- package/lib/dist/ref-map.d.ts +15 -0
- package/lib/dist/ref-map.d.ts.map +1 -1
- package/lib/dist/ref-map.js +48 -0
- package/lib/dist/resource/index.d.ts +0 -0
- package/lib/dist/resource/index.d.ts.map +0 -0
- package/lib/dist/resource/index.js +5 -0
- package/lib/dist/resource/program.d.ts +2 -2
- package/lib/dist/resource/program.d.ts.map +1 -1
- package/lib/dist/resource/program.js +20 -0
- package/lib/dist/resource/resource.d.ts +10 -4
- package/lib/dist/resource/resource.d.ts.map +1 -1
- package/lib/dist/resource/resource.js +48 -0
- package/lib/dist/resource/texture2d.d.ts +8 -9
- package/lib/dist/resource/texture2d.d.ts.map +1 -1
- package/lib/dist/resource/texture2d.js +20 -0
- package/lib/dist/resource/textureCube.d.ts +7 -9
- package/lib/dist/resource/textureCube.d.ts.map +1 -1
- package/lib/dist/resource/textureCube.js +17 -0
- package/lib/dist/shader/code.d.ts +12 -0
- package/lib/dist/shader/code.d.ts.map +1 -0
- package/lib/dist/shader/code.js +32 -0
- package/lib/dist/shader/fragment.d.ts +23 -0
- package/lib/dist/shader/fragment.d.ts.map +1 -0
- package/lib/dist/shader/fragment.js +37 -0
- package/lib/dist/shader/vertex.d.ts +23 -0
- package/lib/dist/shader/vertex.d.ts.map +1 -0
- package/lib/dist/shader/vertex.js +35 -0
- package/lib/dist/texture/index.d.ts +0 -0
- package/lib/dist/texture/index.d.ts.map +0 -0
- package/lib/dist/texture/index.js +3 -0
- package/lib/dist/texture/texture2d.d.ts +14 -9
- package/lib/dist/texture/texture2d.d.ts.map +1 -1
- package/lib/dist/texture/texture2d.js +132 -0
- package/lib/dist/texture/textureCube.d.ts +4 -5
- package/lib/dist/texture/textureCube.d.ts.map +1 -1
- package/lib/dist/texture/textureCube.js +87 -0
- package/lib/dist/types/animation.d.ts +20 -0
- package/lib/dist/types/animation.d.ts.map +1 -0
- package/lib/dist/types/animation.js +2 -0
- package/lib/dist/types/arrays.d.ts +33 -0
- package/lib/dist/types/arrays.d.ts.map +1 -0
- package/lib/dist/types/arrays.js +2 -0
- package/lib/dist/types/context.d.ts +25 -0
- package/lib/dist/types/context.d.ts.map +1 -0
- package/lib/dist/types/context.js +2 -0
- package/lib/dist/types/gltf.d.ts +200 -0
- package/lib/dist/types/gltf.d.ts.map +1 -0
- package/lib/dist/types/gltf.js +117 -0
- package/lib/dist/types/guards.d.ts +25 -0
- package/lib/dist/types/guards.d.ts.map +1 -0
- package/lib/dist/types/guards.js +218 -0
- package/lib/dist/types/index.d.ts +5 -0
- package/lib/dist/types/index.d.ts.map +1 -1
- package/lib/dist/types/index.js +10 -0
- package/lib/dist/types/input-keyboard.d.ts +8 -0
- package/lib/dist/types/input-keyboard.d.ts.map +1 -0
- package/lib/dist/types/input-keyboard.js +2 -0
- package/lib/dist/types/input-pointer.d.ts +42 -0
- package/lib/dist/types/input-pointer.d.ts.map +1 -0
- package/lib/dist/types/input-pointer.js +2 -0
- package/lib/dist/types/mesh.d.ts +10 -0
- package/lib/dist/types/mesh.d.ts.map +1 -0
- package/lib/dist/types/mesh.js +2 -0
- package/lib/dist/types/painter.d.ts +2 -0
- package/lib/dist/types/painter.d.ts.map +1 -0
- package/lib/dist/types/painter.js +2 -0
- package/lib/dist/types/program.d.ts +15 -0
- package/lib/dist/types/program.d.ts.map +1 -1
- package/lib/dist/types/program.js +2 -0
- package/lib/dist/types/texture2d.d.ts +20 -8
- package/lib/dist/types/texture2d.d.ts.map +1 -1
- package/lib/dist/types/texture2d.js +2 -0
- package/lib/dist/types/textureCube.d.ts +42 -3
- package/lib/dist/types/textureCube.d.ts.map +1 -1
- package/lib/dist/types/textureCube.js +2 -0
- package/lib/dist/types/webgl.d.ts +28 -0
- package/lib/dist/types/webgl.d.ts.map +1 -1
- package/lib/dist/types/webgl.js +2 -0
- package/lib/dist/utils/action/camera.d.ts +13 -0
- package/lib/dist/utils/action/camera.d.ts.map +1 -0
- package/lib/dist/utils/action/camera.js +30 -0
- package/lib/dist/utils/action/index.d.ts +2 -0
- package/lib/dist/utils/action/index.d.ts.map +1 -0
- package/lib/dist/utils/action/index.js +2 -0
- package/lib/dist/utils/canvas.d.ts +13 -0
- package/lib/dist/utils/canvas.d.ts.map +1 -0
- package/lib/dist/utils/canvas.js +23 -0
- package/lib/dist/utils/ease-func/ease-func.d.ts +32 -0
- package/lib/dist/utils/ease-func/ease-func.d.ts.map +1 -0
- package/lib/dist/utils/ease-func/ease-func.js +142 -0
- package/lib/dist/utils/ease-func/index.d.ts +2 -0
- package/lib/dist/utils/ease-func/index.d.ts.map +1 -0
- package/lib/dist/utils/ease-func/index.js +2 -0
- package/lib/dist/utils/fetch/fetch.d.ts +2 -0
- package/lib/dist/utils/fetch/fetch.d.ts.map +1 -0
- package/lib/dist/utils/fetch/fetch.js +5 -0
- package/lib/dist/utils/fetch/index.d.ts +2 -0
- package/lib/dist/utils/fetch/index.d.ts.map +1 -0
- package/lib/dist/utils/fetch/index.js +2 -0
- package/lib/dist/utils/fullscreen.d.ts +21 -0
- package/lib/dist/utils/fullscreen.d.ts.map +1 -0
- package/lib/dist/utils/fullscreen.js +64 -0
- package/lib/dist/utils/index.d.ts +6 -0
- package/lib/dist/utils/index.d.ts.map +1 -0
- package/lib/dist/utils/index.js +6 -0
- package/lib/dist/utils/math.d.ts +3 -0
- package/lib/dist/utils/math.d.ts.map +1 -0
- package/lib/dist/utils/math.js +11 -0
- package/lib/dist/utils/ref-map.d.ts +22 -0
- package/lib/dist/utils/ref-map.d.ts.map +1 -0
- package/lib/dist/utils/ref-map.js +48 -0
- package/lib/dist/vao/index.d.ts +0 -0
- package/lib/dist/vao/index.d.ts.map +0 -0
- package/lib/dist/vao/index.js +2 -0
- package/lib/dist/vao/vao.d.ts +7 -3
- package/lib/dist/vao/vao.d.ts.map +1 -1
- package/lib/dist/vao/vao.js +67 -0
- package/package.json +6 -5
- package/lib/dist/mesh/mesh.d.ts +0 -11
- package/lib/dist/mesh/mesh.d.ts.map +0 -1
- package/lib/dist/painter/isometric/isometric.frag.d.ts +0 -3
- package/lib/dist/painter/isometric/isometric.frag.d.ts.map +0 -1
- package/lib/dist/painter/isometric/isometric.vert.d.ts +0 -3
- package/lib/dist/painter/isometric/isometric.vert.d.ts.map +0 -1
- package/lib/dist/painter/primitive/primitive.frag.d.ts +0 -3
- package/lib/dist/painter/primitive/primitive.frag.d.ts.map +0 -1
- package/lib/dist/painter/primitive/primitive.vert.d.ts +0 -3
- package/lib/dist/painter/primitive/primitive.vert.d.ts.map +0 -1
- package/lib/dist/painter/sprites/sprites-painter.frag.d.ts +0 -3
- package/lib/dist/painter/sprites/sprites-painter.frag.d.ts.map +0 -1
- package/lib/dist/painter/sprites/sprites-painter.vert.d.ts +0 -3
- package/lib/dist/painter/sprites/sprites-painter.vert.d.ts.map +0 -1
package/lib/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
export * from "./camera";
|
|
2
|
+
export * from "./canvas";
|
|
3
|
+
export * from "./color";
|
|
2
4
|
export * from "./context";
|
|
3
5
|
export * from "./controller";
|
|
4
6
|
export * from "./dataset";
|
|
7
|
+
export * from "./event";
|
|
8
|
+
export * from "./filter";
|
|
9
|
+
export * from "./geometry";
|
|
5
10
|
export * from "./input";
|
|
11
|
+
export * from "./light";
|
|
12
|
+
export * from "./material";
|
|
6
13
|
export * from "./math";
|
|
7
14
|
export * from "./painter";
|
|
15
|
+
export * from "./painter/painter";
|
|
8
16
|
export * from "./parser";
|
|
9
17
|
export * from "./resource";
|
|
18
|
+
export * from "./utils";
|
|
10
19
|
export * from "./vao";
|
|
11
20
|
export * from "./types";
|
|
12
21
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,OAAO,CAAA;AAErB,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AAErB,cAAc,SAAS,CAAA"}
|
package/lib/dist/index.js
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
|
-
var t={d:(i,e)=>{for(var s in e)t.o(e,s)&&!t.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:e[s]})},o:(t,i)=>Object.prototype.hasOwnProperty.call(t,i)},i={};function e(t,i=6){const e=Math.pow(10,i),s=[];let r=0;for(const n of t){const t=(Math.round(n*e)/e).toFixed(i);r=Math.max(r,t.length),s.push(t)}return s.map((t=>t.padStart(r," ")))}t.d(i,{Uj:()=>L,w1:()=>M,$M:()=>z,aT:()=>m,OY:()=>l,yr:()=>d,Zc:()=>X,tz:()=>S,Yp:()=>D,Wk:()=>r,pD:()=>Z,WM:()=>F,Op:()=>V,ui:()=>g,ts:()=>C,sh:()=>O,a7:()=>k,EK:()=>h,cX:()=>f,qG:()=>b,Ui:()=>s,YE:()=>n,Zk:()=>R});class s extends Float32Array{constructor(t=0,i=0,e=0){if(super(3),"number"!=typeof t)return this.x=t.x,this.y=t.y,void(this.z=t.z);this.x=t,this.y=i,this.z=e}clone(){return new s(this)}isEqual({x:t,y:i,z:e}){return t===this.x&&i===this.y&&e===this.z}isClose({x:t,y:i,z:e},s=1e-6){return!(Math.abs(t-this.x)>s||Math.abs(i-this.y)>s||Math.abs(e-this.z)>s)}rotateAround(t,i){const e=Math.cos(i),s=Math.sin(i),[r,n,h]=this,[o,a,c]=t,u=a*h-c*n,m=c*r-o*h,l=o*n-a*r,d=(r*o+n*a+h*c)*(1-e);return this.x=r*e+u*s+o*d,this.y=n*e+m*s+a*d,this.z=h*e+l*s+c*d,this}applyMatrix(t){const{x:i,y:e,z:s}=this;return this.x=i*t.m00+e*t.m10+s*t.m20,this.y=i*t.m01+e*t.m11+s*t.m21,this.z=i*t.m02+e*t.m12+s*t.m22,this}from({x:t,y:i,z:e}){return this.x=t,this.y=i,this.z=e,this}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}add(...t){for(const i of t)this[0]+=i[0],this[1]+=i[1],this[2]+=i[2];return this}addWithScale({x:t,y:i,z:e},s=1){return this[0]+=t*s,this[1]+=i*s,this[2]+=e*s,this}subtract(t){return this[0]-=t[0],this[1]-=t[1],this[2]-=t[2],this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]}get size(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2])}normalize(){const t=this[0]*this[0]+this[1]*this[1]+this[2]*this[2];return 0===t?this:this.scale(1/Math.sqrt(t))}debug(t="vec3"){const{x:i,y:e,z:s}=this,r=[i,e,s].map((t=>t.toFixed(6)));console.log(`${t}: `,r.join(" | ")," length:",Math.sqrt(i*i+e*e+s*s))}}class r extends Float32Array{constructor(t=1,i=0,e=0,s=0,r=0,n=1,h=0,o=0,a=0,c=0,u=1,m=0,l=0,d=0,g=0,f=1){super("number"==typeof t?[t,i,e,s,r,n,h,o,a,c,u,m,l,d,g,f]:t)}multiply(t){const[i,e,s,r,n,h,o,a,c,u,m,l,d,g,f,x]=this,[p,y,v,w,b,E,_,T,A,P,U,M,z,I,R,X]=t;return this.m00=i*p+n*y+c*v+d*w,this.m10=i*b+n*E+c*_+d*T,this.m20=i*A+n*P+c*U+d*M,this.m30=i*z+n*I+c*R+d*X,this.m01=e*p+h*y+u*v+g*w,this.m11=e*b+h*E+u*_+g*T,this.m21=e*A+h*P+u*U+g*M,this.m31=e*z+h*I+u*R+g*X,this.m02=s*p+o*y+m*v+f*w,this.m12=s*b+o*E+m*_+f*T,this.m22=s*A+o*P+m*U+f*M,this.m32=s*z+o*I+m*R+f*X,this.m03=r*p+a*y+l*v+x*w,this.m13=r*b+a*E+l*_+x*T,this.m23=r*A+a*P+l*U+x*M,this.m33=r*z+a*I+l*R+x*X,this}invert(){const[t,i,e,s,r,n,h,o,a,c,u,m,l,d,g,f]=this,x=t*n-i*r,p=t*h-e*r,y=t*o-s*r,v=i*h-e*n,w=i*o-s*n,b=e*o-s*h,E=a*d-c*l,_=a*g-u*l,T=a*f-m*l,A=c*g-u*d,P=c*f-m*d,U=u*f-m*g,M=x*U-p*P+y*A+v*T-w*_+b*E;if(!M)return this;const z=1/M;return this[0]=(n*U-h*P+o*A)*z,this[1]=(e*P-i*U-s*A)*z,this[2]=(d*b-g*w+f*v)*z,this[3]=(u*w-c*b-m*v)*z,this[4]=(h*T-r*U-o*_)*z,this[5]=(t*U-e*T+s*_)*z,this[6]=(g*y-l*b-f*p)*z,this[7]=(a*b-u*y+m*p)*z,this[8]=(r*P-n*T+o*E)*z,this[9]=(i*T-t*P-s*E)*z,this[10]=(l*w-d*y+f*x)*z,this[11]=(c*y-a*w-m*x)*z,this[12]=(n*_-r*A-h*E)*z,this[13]=(t*A-i*_+e*E)*z,this[14]=(d*p-l*v-g*x)*z,this[15]=(a*v-c*p+u*x)*z,this}get translation(){const{m30:t,m31:i,m32:e}=this;return new s(t,i,e)}set translation(t){this.m30=t.x,this.m31=t.y,this.m32=t.z}from(t){return this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m13=t.m13,this.m20=t.m20,this.m21=t.m21,this.m22=t.m22,this.m23=t.m23,this.m30=t.m30,this.m31=t.m31,this.m32=t.m32,this.m33=t.m33,this}fromMat3(t){return this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m20=t.m20,this.m21=t.m21,this.m22=t.m22,this}toAxis(t,i,e){return this.toAxisX(t),this.toAxisY(i),this.toAxisZ(e)}toAxisX(t){return t.x=this.m00,t.y=this.m01,t.z=this.m02,this}toAxisY(t){return t.x=this.m10,t.y=this.m11,t.z=this.m12,this}toAxisZ(t){return t.x=this.m20,t.y=this.m21,t.z=this.m22,this}fromQuat({x:t,y:i,z:e,w:s}){const r=t+t,n=i+i,h=e+e,o=t*r,a=i*r,c=i*n,u=e*r,m=e*n,l=e*h,d=s*r,g=s*n,f=s*h;return this.m00=1-c-l,this.m10=a-f,this.m20=u+g,this.m01=a+f,this.m11=1-o-l,this.m21=m-d,this.m02=u-g,this.m12=m+d,this.m22=1-o-c,this}get m00(){return this[0]}set m00(t){this[0]=t}get m01(){return this[1]}set m01(t){this[1]=t}get m02(){return this[2]}set m02(t){this[2]=t}get m03(){return this[3]}set m03(t){this[3]=t}get m10(){return this[4]}set m10(t){this[4]=t}get m11(){return this[5]}set m11(t){this[5]=t}get m12(){return this[6]}set m12(t){this[6]=t}get m13(){return this[7]}set m13(t){this[7]=t}get m20(){return this[8]}set m20(t){this[8]=t}get m21(){return this[9]}set m21(t){this[9]=t}get m22(){return this[10]}set m22(t){this[10]=t}get m23(){return this[11]}set m23(t){this[11]=t}get m30(){return this[12]}set m30(t){this[12]=t}get m31(){return this[13]}set m31(t){this[13]=t}get m32(){return this[14]}set m32(t){this[14]=t}get m33(){return this[15]}set m33(t){this[15]=t}debug(t="Mat4"){const i=e([this.m00,this.m01,this.m02,this.m03]),s=e([this.m10,this.m11,this.m12,this.m13]),r=e([this.m20,this.m21,this.m22,this.m23]),n=e([this.m30,this.m31,this.m32,this.m33]);console.log(t),console.log(" ",[i[0],s[0],r[0],n[0]].join(" | ")),console.log(" ",[i[1],s[1],r[1],n[1]].join(" | ")),console.log(" ",[i[2],s[2],r[2],n[2]].join(" | ")),console.log(" ",[i[3],s[3],r[3],n[3]].join(" | "))}}class n extends Float32Array{constructor(t=0,i=0,e=0,r=1){return super(4),t instanceof n?(this.x=t.x,this.y=t.y,this.z=t.z,void(this.w=t.w)):t instanceof s?(this.x=t.x,this.y=t.y,this.z=t.z,void(this.w=r)):(this.x=t,this.y=i,this.z=e,void(this.w=r))}reset(t=0,i=0,e=0,s=1){return this.x=t,this.y=i,this.z=e,this.w=s,this}from(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}clone(){return new n(this)}isEqual({x:t,y:i,z:e,w:s}){return t===this.x&&i===this.y&&e===this.z&&s===this.w}isClose({x:t,y:i,z:e,w:s},r=1e-6){return!(Math.abs(t-this.x)>r||Math.abs(i-this.y)>r||Math.abs(e-this.z)>r||Math.abs(s-this.w)>r)}applyMatrix(t){const{x:i,y:e,z:s,w:r}=this;return this.x=i*t.m00+e*t.m10+s*t.m20+r*t.m30,this.y=i*t.m01+e*t.m11+s*t.m21+r*t.m31,this.z=i*t.m02+e*t.m12+s*t.m22+r*t.m32,this.w=i*t.m03+e*t.m13+s*t.m23+r*t.m33,this}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}get w(){return this[3]}set w(t){this[3]=t}add(...t){for(const i of t)this[0]+=i[0],this[1]+=i[1],this[2]+=i[2],this[3]+=i[3];return this}subtract(t){return this[0]-=t[0],this[1]-=t[1],this[2]-=t[2],this[3]-=t[3],this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this[3]*=t,this}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]+this[3]*t[3]}get size(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3])}normalize(){const t=this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3];return 0===t?this:this.scale(1/Math.sqrt(t))}debug(t="vec4"){const{x:i,y:e,z:s,w:r}=this,n=[i,e,s,r].map((t=>t.toFixed(6)));console.log(`${t}: `,n.join(" | "))}}class h extends n{constructor(t=0,i=0,e=0,s=1){"number"==typeof t?super(t,i,e,s):super(t)}clone(){return new h(this)}multiply(t){const[i,e,s,r]=this,[n,h,o,a]=t;return this[0]=a*i+n*r-h*s+o*e,this[1]=a*e+n*s+h*r-o*i,this[2]=a*s-n*e+h*i+o*r,this[3]=a*r-n*i-h*e-o*s,this}fromAxis(t,i,e){const s=t.x+i.y+e.z;if(s>0){const r=Math.sqrt(s+1);this.w=.5*r;const n=.5/r;this.x=(i.z-e.y)*n,this.y=(e.x-t.z)*n,this.z=(t.y-i.x)*n}else{const s=[t,i,e];let r=0;i.y>t.x&&(r=1),e.z>s[r][r]&&(r=2);const n=(r+1)%3,h=(r+2)%3;let o=Math.sqrt(s[r][r]-s[n][n]-s[h][h]+1);this[r]=.5*o,o=.5/o,this[3]=(s[n][h]-s[h][n])*o,this[n]=(s[n][r]+s[r][n])*o,this[h]=(s[h][r]+s[r][h])*o}return this.normalize()}rotateAroundX(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o+n*h,this[1]=s*o+r*h,this[2]=r*o-s*h,this[3]=n*o-e*h,this}rotateAroundY(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o-r*h,this[1]=s*o+n*h,this[2]=r*o+e*h,this[3]=n*o-s*h,this}rotateAroundZ(t){const i=.5*t,e=this[0],s=this[1],r=this[2],n=this[3],h=Math.sin(i),o=Math.cos(i);return this[0]=e*o+s*h,this[1]=s*o-e*h,this[2]=r*o+n*h,this[3]=n*o-r*h,this}toAxisZ(t){const{x:i,y:e,z:s,w:r}=this,n=i+i,h=e+e,o=i*n,a=e*h,c=s*n,u=s*h,m=r*n,l=r*h;return t.x=c+l,t.y=u-m,t.z=1-o-a,t}face(t="+X+Y+Z"){const[i,e,s,r]=c[t];return this.x=i,this.y=e,this.z=s,this.w=r,this}}const o=Math.sqrt(2)/2,a=.5,c={"+X+Y+Z":[0,0,0,1],"-Z+Y+X":[0,+o,0,+o],"-X+Y-Z":[0,1,0,0],"+Z+Y-X":[0,-o,0,+o],"+X+Z-Y":[+o,0,0,+o],"+Y+Z+X":[+a,+a,+a,+a],"-X+Z+Y":[0,+o,+o,0],"-Y+Z-X":[+a,-a,-a,+a],"+X-Y-Z":[1,0,0,0],"+X-Z+Y":[-o,0,0,+o],"-X-Y+Z":[0,0,1,0],"-X-Z-Y":[0,+o,-o,0],"+Y+X-Z":[+o,+o,0,0],"+Y-X+Z":[0,0,+o,+o],"+Y-Z-X":[+a,+a,-a,-a],"-Y+X+Z":[0,0,-o,+o],"-Y-X-Z":[+o,-o,0,0],"-Y-Z+X":[+a,-a,+a,-a],"+Z+X+Y":[+a,+a,+a,-a],"+Z-X-Y":[+a,-a,+a,+a],"+Z-Y+X":[+o,0,+o,0],"-Z+X-Y":[+a,+a,-a,+a],"-Z-X+Y":[+a,-a,-a,-a],"-Z-Y-X":[+o,0,-o,0]};class u extends Float32Array{constructor(t=1,i=0,e=0,s=0,r=1,n=0,h=0,o=0,a=1){super("number"==typeof t?[t,i,e,s,r,n,h,o,a]:t)}transpose(){let t=this.m10;return this.m10=this.m01,this.m01=t,t=this.m20,this.m20=this.m02,this.m02=t,t=this.m21,this.m21=this.m12,this.m12=t,this}fromQuat({x:t,y:i,z:e,w:s}){const r=t+t,n=i+i,h=e+e,o=t*r,a=i*r,c=i*n,u=e*r,m=e*n,l=e*h,d=s*r,g=s*n,f=s*h;return this.m00=1-c-l,this.m10=a-f,this.m20=u+g,this.m01=a+f,this.m11=1-o-l,this.m21=m-d,this.m02=u-g,this.m12=m+d,this.m22=1-o-c,this}toAxis(t,i,e){return this.toAxisX(t),this.toAxisY(i),this.toAxisZ(e)}toAxisX(t){return t.x=this.m00,t.y=this.m01,t.z=this.m02,this}toAxisY(t){return t.x=this.m10,t.y=this.m11,t.z=this.m12,this}toAxisZ(t){return t.x=this.m20,t.y=this.m21,t.z=this.m22,this}scale(t){return this[0]*=t,this[1]*=t,this[2]*=t,this[3]*=t,this[4]*=t,this[5]*=t,this[6]*=t,this[7]*=t,this[8]*=t,this}get m00(){return this[0]}set m00(t){this[0]=t}get m01(){return this[1]}set m01(t){this[1]=t}get m02(){return this[2]}set m02(t){this[2]=t}get m10(){return this[3]}set m10(t){this[3]=t}get m11(){return this[4]}set m11(t){this[4]=t}get m12(){return this[5]}set m12(t){this[5]=t}get m20(){return this[6]}set m20(t){this[6]=t}get m21(){return this[7]}set m21(t){this[7]=t}get m22(){return this[8]}set m22(t){this[8]=t}debug(t="Mat3"){const i=e([this.m00,this.m01,this.m02]),s=e([this.m10,this.m11,this.m12]),r=e([this.m20,this.m21,this.m22]);console.log(t),console.log(" ",[i[0],s[0],r[0]].join(" | ")),console.log(" ",[i[1],s[1],r[1]].join(" | ")),console.log(" ",[i[2],s[2],r[2]].join(" | "))}}class m{constructor(){this.dirty=!0,this.dirtyAxis=!0,this.axisX=new s,this.axisY=new s,this.axisZ=new s,this._matrixViewModel=new r,this.orientation=new h(0,0,0,1),this.target=new s(0,0,0),this._distance=10,this._zoom=1,this.tmpMat3=new u,this.tmpVec3=new s,this.orientation.face("+X+Y+Z"),this.orbitAroundY(Math.PI),this.updateAxisIfNeeded(),console.log("****************************************"),this.axisX.debug("X"),this.axisY.debug("Y"),this.axisZ.debug("Z"),this.matrixViewModel.debug(),this.orientation.debug("Quat");const t=(t,i)=>Math.abs(t-i)<1e-5,i=({x:i,y:e,z:s})=>t(i,1)?"+X":t(i,-1)?"-X":t(e,1)?"+Y":t(e,-1)?"-Y":t(s,1)?"+Z":t(s,-1)?"-Z":"??",e=[new s(1,0,0),new s(-1,0,0),new s(0,1,0),new s(0,-1,0),new s(0,0,1),new s(0,0,-1)],n=Math.sqrt(2)/2,o=({x:i,y:e,z:s,w:r})=>[i,e,s,r].map((i=>t(i,0)?"+0":t(i,1)?"+1":t(i,-1)?"-1":t(i,+n)?"+A":t(i,-n)?"-A":t(i,.5)?"+H":t(i,-.5)?"-H":i)).join(", "),a=([t,i,e],[s,r,n])=>{const h=t*s+i*r+e*n;return Math.abs(h)>.5},c=([t,i,e],[s,r,n],[h,o,a])=>{const c=i*n-r*e+h,u=s*e-t*n+o,m=t*r-s*i+a;return Math.abs(c*c+u*u+m*m)>.01},m=[];for(const t of e)for(const s of e)if(!a(t,s))for(const r of e)a(t,r)||a(s,r)||c(t,s,r)&&(this.orientation.fromAxis(t,s,r),this.updateAxis(),m.push(`\n"${i(t)}${i(s)}${i(r)}": [${o(this.orientation)}],`));console.log(m.join("")),this.orientation.face()}face(t){this.orientation.face(t),this.dirty=!0,this.dirtyAxis=!0}from({orientation:t,target:i,distance:e,zoom:s}){return this.orientation.from(t),this.target.from(i),this.distance=e,this.zoom=s,this.dirty=!0,this.dirtyAxis=!0,this}toAxisX(t){return this.updateAxisIfNeeded(),t.from(this.axisX),this}toAxisY(t){return this.updateAxisIfNeeded(),t.from(this.axisY),this}toAxisZ(t){return this.updateAxisIfNeeded(),t.from(this.axisZ),this}get matrixViewModel(){return this.updateIfNeeded(),this._matrixViewModel}setOrientation(t){const{orientation:i}=this;if(t.isEqual(i))return;const[e,s,r,n]=t;i.x=e,i.y=s,i.z=r,i.w=n,this.dirty=!0,this.dirtyAxis=!0}setTarget(t){const{target:i}=this;if(t.isEqual(i))return;const[e,s,r]=t;i.x=e,i.y=s,i.z=r,this.dirty=!0}get x(){return this.target.x}set x(t){const{target:i}=this;t!==i.x&&(this.x=t,this.dirty=!0)}get y(){return this.target.y}set y(t){const{target:i}=this;t!==i.y&&(this.y=t,this.dirty=!0)}get z(){return this.target.z}set z(t){const{target:i}=this;t!==i.z&&(this.z=t,this.dirty=!0)}get distance(){return this._distance}set distance(t){this._distance!==t&&(this._distance=t,this.dirty=!0)}get zoom(){return this._zoom}set zoom(t){this._zoom!==t&&(this._zoom=t,this.dirty=!0)}moveTarget(t,i,e){const{target:s}=this;this.updateAxisIfNeeded();const{axisX:r,axisY:n,axisZ:h,tmpVec3:o}=this;o.from(r).scale(t).addWithScale(n,i).addWithScale(h,e),s.x+=o.x,s.y+=o.y,s.z+=o.z,this.dirty=!0}orbitAroundX(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return e.rotateAround(i,t),s.rotateAround(i,t),r.fromAxis(i,e,s),this.dirty=!0,this}orbitAroundY(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return i.rotateAround(e,t),s.rotateAround(e,t),r.fromAxis(i,e,s),this.dirty=!0,this}orbitAroundZ(t){this.updateAxisIfNeeded();const{axisX:i,axisY:e,axisZ:s,orientation:r}=this;return i.rotateAround(s,t),e.rotateAround(s,t),r.fromAxis(i,e,s),this.dirty=!0,this}debug(t="Camera"){this.orientation.debug(`${t} quaternion:`)}updateAxisIfNeeded(){this.dirtyAxis&&this.updateAxis()}updateAxis(){const{tmpMat3:t}=this;if(t.fromQuat(this.orientation),t.toAxis(this.axisX,this.axisY,this.axisZ),this.dirtyAxis=!1,Math.abs(1-this.axisX.size)>.1||Math.abs(1-this.axisY.size)>.1||Math.abs(1-this.axisZ.size)>.1)throw this.axisX.debug("Axis X"),this.axisY.debug("Axis Y"),this.axisZ.debug("Axis Z"),Error("STOP!")}updateIfNeeded(){if(!this.dirty)return;const{tmpMat3:t,tmpVec3:i}=this,e=this._matrixViewModel;this.updateAxis();const s=this._distance,{x:r,y:n,z:h}=this.target,{x:o,y:a,z:c}=this.axisZ;i.x=r+s*o,i.y=n+s*a,i.z=h+s*c,i.applyMatrix(t.transpose()).scale(-1),e.m30=i.x,e.m31=i.y,e.m32=i.z;const u=this._zoom;1!==u&&t.scale(u),e.fromMat3(t),this.dirty=!1}}class l extends m{constructor(){super(),this.dirtyProjection=!0,this._matrixProjection=new r,this._width=1920,this._height=1080,this._spaceHeight=10,this._near=.001,this._far=1e3}get spaceHeight(){return this._spaceHeight}set spaceHeight(t){t!==this._spaceHeight&&(this._spaceHeight=t,this.dirtyProjection=!0)}get screenWidth(){return this._width}set screenWidth(t){t!==this._width&&(this._width=t,this.dirtyProjection=!0)}get screenHeight(){return this._height}set screenHeight(t){t!==this._height&&(this._height=t,this.dirtyProjection=!0)}get near(){return this._near}set near(t){t!==this._near&&(this._near=t,this.dirtyProjection=!0)}get far(){return this._far}set far(t){t!==this._far&&(this._far=t,this.dirtyProjection=!0)}get matrixProjection(){return this.updateProjectionIfNeeded(),this._matrixProjection}updateProjectionIfNeeded(){if(!this.dirtyProjection)return;const{near:t,far:i,_width:e,_height:s,_spaceHeight:r}=this,n=.5*r,h=-n,o=n*e/s,a=-o,c=this._matrixProjection,u=1/(a-o),m=1/(h-n),l=1/(t-i);c[0]=-2*u,c[1]=0,c[2]=0,c[3]=0,c[4]=0,c[5]=-2*m,c[6]=0,c[7]=0,c[8]=0,c[9]=0,c[10]=l,c[11]=0,c[12]=(a+o)*u,c[13]=(n+h)*m,c[14]=t*l,c[15]=1,this.dirtyProjection=!0}}class d extends m{constructor(){super(),this.dirtyProjection=!0,this._matrixProjection=new r,this._width=1920,this._height=1080,this._fovy=Math.PI/4,this._near=.001,this._far=1/0}get screenWidth(){return this._width}set screenWidth(t){t!==this._width&&(this._width=t,this.dirtyProjection=!0)}get screenHeight(){return this._height}set screenHeight(t){t!==this._height&&(this._height=t,this.dirtyProjection=!0)}get fovy(){return this._fovy}set fovy(t){t!==this._fovy&&(this._fovy=t,this.dirtyProjection=!0)}get near(){return this._near}set near(t){t!==this._near&&(this._near=t,this.dirtyProjection=!0)}get far(){return this._far}set far(t){t!==this._far&&(this._far=t,this.dirtyProjection=!0)}get matrixProjection(){return this.updateProjectionIfNeeded(),this._matrixProjection}updateProjectionIfNeeded(){if(!this.dirtyProjection)return;const t=this._fovy,i=this._width/this._height,e=this._near,s=this._far,r=this._matrixProjection,n=1/Math.tan(t/2);if(r[0]=n/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=n,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!==1/0){const t=1/(e-s);r[10]=(s+e)*t,r[14]=2*s*e*t}else r[10]=-1,r[14]=-2*e;this.dirtyProjection=!0}}class g{constructor(t=[]){this.enabled=!0,this.painters=[...t]}add(...t){for(const i of t)this.painters.push(i)}remove(...t){for(const i of t){const t=this.painters.indexOf(i);t<0||(this.painters.splice(t,1),i.delete())}}delete(){for(const t of this.painters)t.delete();this.painters.splice(0,this.painters.length)}paint(t,i){if(this.enabled)for(const e of this.painters)e.paint(t,i)}update(t,i){if(this.enabled)for(const e of this.painters)e.update(t,i)}}class f{constructor(){this.keys=new Map,this.objects=new Map,this.references=new Map}create(t){var i;const e=this.makeKeyFromInput(t),s=null!==(i=this.references.get(e))&&void 0!==i?i:0;if(s<1){const i=this.actualCreate(t);return this.keys.set(i,e),this.objects.set(e,i),this.references.set(e,1),i}const r=this.objects.get(e);if(!r)throw Error("[TgdResource.create] Panic!");return this.references.set(e,s+1),r}delete(t){var i;const e=this.keys.get(t);if(!e)return;const s=null!==(i=this.references.get(e))&&void 0!==i?i:0;s<1||(s>1?this.references.set(e,s-1):(this.keys.delete(t),this.objects.delete(e),this.references.delete(e),this.actualDelete(t)))}}class x{constructor(t,i){var e;this.gl=t;const s=t.createProgram();if(!s)throw Error("Unable to create WebGLProgram!");const r=this.createShader("VERTEX_SHADER",i.vert);t.attachShader(s,r);const n=this.createShader("FRAGMENT_SHADER",i.frag);if(t.attachShader(s,n),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS)){var h=null!==(e=t.getProgramInfoLog(s))&&void 0!==e?e:"";console.warn(h);const r=y(h);throw w("Vertex Shader",i.vert,...r),w("Fragment Shader",i.frag,...r),new Error("Could NOT link WebGL2 program!\n"+h)}this.program=s,this.shaders=[r,n],this.uniformsLocations=this.getUniformsLocations()}getAttribLocation(t){const{gl:i,program:e}=this,s=i.getAttribLocation(e,t);if(s<0)throw Error(`Attribute "${t}" not found!`);return s}getUniformLocation(t){const{uniformsLocations:i}=this,e=Object.keys(i);if(0===t.length)throw Error(`Uniform "${t}" has not been found: there is no active uniform in this program!`);const s=i[t];if(!s)throw Error(`No active uniform found with name "${t}"!\nAvailable names are: ${e.join(", ")}.`);return s}uniform1f(t,i){const{gl:e}=this;e.uniform1f(this.getUniformLocation(t),i)}uniform2f(t,i,e){const{gl:s}=this;s.uniform2f(this.getUniformLocation(t),i,e)}uniform3f(t,i,e,s){const{gl:r}=this;r.uniform3f(this.getUniformLocation(t),i,e,s)}uniform3fv(t,i){const{gl:e}=this;e.uniform3fv(this.getUniformLocation(t),i)}uniform4f(t,i,e,s,r){const{gl:n}=this;n.uniform4f(this.getUniformLocation(t),i,e,s,r)}uniform4fv(t,i){const{gl:e}=this;e.uniform4fv(this.getUniformLocation(t),i)}uniform1i(t,i){const{gl:e}=this;e.uniform1i(this.getUniformLocation(t),i)}uniform2i(t,i,e){const{gl:s}=this;s.uniform2i(this.getUniformLocation(t),i,e)}uniform3i(t,i,e,s){const{gl:r}=this;r.uniform3i(this.getUniformLocation(t),i,e,s)}uniform4i(t,i,e,s,r){const{gl:n}=this;n.uniform4i(this.getUniformLocation(t),i,e,s,r)}uniform1ui(t,i){const{gl:e}=this;e.uniform1ui(this.getUniformLocation(t),i)}uniform2ui(t,i,e){const{gl:s}=this;s.uniform2ui(this.getUniformLocation(t),i,e)}uniform3ui(t,i,e,s){const{gl:r}=this;r.uniform3ui(this.getUniformLocation(t),i,e,s)}uniform4ui(t,i,e,s,r){const{gl:n}=this;n.uniform4ui(this.getUniformLocation(t),i,e,s,r)}uniformMatrix4fv(t,i){const{gl:e}=this;e.uniformMatrix4fv(this.getUniformLocation(t),!1,i)}use(){const{gl:t,program:i}=this;t.useProgram(i)}delete(){const{gl:t}=this;this.shaders.forEach((i=>t.deleteShader(i))),t.deleteProgram(this.program)}createShader(t,i){const{gl:e}=this,s=e.createShader(e[t]);if(!s)throw Error(`Unable to create a WebGLShader of type "${t}"!`);e.shaderSource(s,i),e.compileShader(s);const r=e.getShaderInfoLog(s);if(r)throw console.error(`Error in ${t} code:`,r),w(t,i,...y(r)),Error(`Unable to compile ${t}!`);return s}getUniformsLocations(){const{gl:t,program:i}=this,e=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);if("number"!=typeof e)throw Error("Unable to get the number of uniforms in a WebGLProgram!");const s={};for(let r=0;r<e;r++){const e=t.getActiveUniform(i,r);if(!e)continue;const n=t.getUniformLocation(i,e.name);if(null===n)throw Error(`Unable to get location for uniform "${e.name}"!`);s[e.name]=n}return s}}const p=/^ERROR:[ \t]+([0-9]+):([0-9]+):/g;function y(t){const i=[];for(const e of t.split("\n")){p.lastIndex=-1;const t=p.exec(e);t&&i.push(parseInt(t[2],10))}return i}function v(t,i=!1){return`color:#fff;background:${t};font-family:monospace;font-size:80%;font-weight:${i?"bolder":"100"}`}function w(t,i,...e){console.log(`%c${t}`,"font-weight:bolder;font-size:120%"),i.split("\n").forEach(((t,i)=>{const s=i+1,r=(1e-4*s).toFixed(4).substring(2),n=e.includes(s)?"#f00":"#000";console.log(`%c${r} %c${t}`,v(n),v(n,!0))}))}class b extends f{constructor(t){super(),this.gl=t}actualCreate(t){return new x(this.gl,t)}actualDelete(t){t instanceof x&&t.delete()}makeKeyFromInput(t){return JSON.stringify(t)}}var E=function(t,i,e,s){return new(e||(e=Promise))((function(r,n){function h(t){try{a(s.next(t))}catch(t){n(t)}}function o(t){try{a(s.throw(t))}catch(t){n(t)}}function a(t){var i;t.done?r(t.value):(i=t.value,i instanceof e?i:new e((function(t){t(i)}))).then(h,o)}a((s=s.apply(t,i||[])).next())}))};class _{static image(t){return E(this,void 0,void 0,(function*(){return new Promise((i=>{const e=new Image;e.onload=()=>i(e),e.onerror=()=>{console.error("Unable to load image: ",t),i(null)},e.src=t}))}))}static canvas(t){return E(this,void 0,void 0,(function*(){const i=yield _.image(t);if(!i)return null;const e=document.createElement("canvas");e.width=i.naturalWidth,e.height=i.naturalHeight;const s=e.getContext("2d");if(!s)throw Error("Unable to get a 2D context!");return s.drawImage(i,0,0),e}))}}class T{constructor(){this.listeners=new Set}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}dispatch(t){this.listeners.forEach((i=>i(t)))}}const A=new Uint8Array([200,200,200,255]);class P{constructor(t,i,e={}){this.gl=t,this.refresh=i,this.eventImageUpdate=new T,this._width=0,this._height=0,this._image=null,this.options=Object.assign({wrapS:"REPEAT",wrapT:"REPEAT",wrapR:"REPEAT",minFilter:"NEAREST_MIPMAP_LINEAR",magFilter:"LINEAR"},e);const s=t.createTexture();if(!s)throw Error("Unable to create a WebGLTexture!");this.texture=s,t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,A);const{wrapS:r,wrapT:n,wrapR:h,minFilter:o,magFilter:a}=this.options;t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t[r]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t[n]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_R,t[h]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t[o]),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t[a]),e.image&&this.loadImage(e.image)}delete(){this.gl.deleteTexture(this.texture)}get image(){return this._image}get width(){return this._width}get height(){return this._height}bind(){const{gl:t}=this;t.bindTexture(t.TEXTURE_2D,this.texture)}activate(t,i,e=0){const{gl:s,texture:r}=this;s.activeTexture(s.TEXTURE0+e),s.bindTexture(s.TEXTURE_2D,r),t.uniform1i(i,e)}loadImage(t){if("string"==typeof t)return void _.image(t).then((i=>{i?(this.loadImage(i),this.refresh()):console.error("[TgdTexture2D] Unable to load image:",t)})).catch(console.error);const{gl:i,texture:e}=this;i.bindTexture(i.TEXTURE_2D,e),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),i.generateMipmap(i.TEXTURE_2D),this._width=t.width,this._height=t.height,this._image=t,this.eventImageUpdate.dispatch(this)}}class U{constructor(t,i,e){this.gl=t,this.refresh=i,this._width=0,this._height=0,this.numberOfImagesToLoad=6;const s=t.createTexture();if(!s)throw Error("Unable to create a WebGLTexture!");this.texture=s,this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_X,e.imagePosX),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_X,e.imageNegX),this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_Y,e.imagePosY),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.imageNegY),this.loadImage(t.TEXTURE_CUBE_MAP_POSITIVE_Z,e.imagePosZ),this.loadImage(t.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.imageNegZ)}delete(){this.gl.deleteTexture(this.texture)}get ready(){return 0===this.numberOfImagesToLoad}get width(){return this._width}get height(){return this._height}bind(){const{gl:t}=this;t.bindTexture(t.TEXTURE_CUBE_MAP,this.texture)}activate(t,i,e=0){if(!this.ready)return;const{gl:s,texture:r}=this;s.activeTexture(s.TEXTURE0+e),s.bindTexture(s.TEXTURE_CUBE_MAP,r),t.uniform1i(i,e)}loadImage(t,i){if("string"==typeof i)return void _.image(i).then((e=>{e?this.loadImage(t,e):console.error(`[TgdTextureCube] Unable to load image "${i}":`,i)})).catch((t=>{console.error(`[TgdTextureCube] Unable to load image "${i}":`,t)}));const{width:e,height:s}=i;if(e!==s)throw Error(`Images in a CubeMap must be squares, but we got ${e}×${s}!`);if(0===this._width)this._width=e,this._height=s;else if(this._width!==e||this._height!==s)throw Error(`Images in a CubeMap must all have the same size, but we got ${this._width}×${this._height} and ${e}×${s}!`);const{gl:r,texture:n}=this;r.bindTexture(r.TEXTURE_CUBE_MAP,n),r.texImage2D(t,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i),this.numberOfImagesToLoad--,0===this.numberOfImagesToLoad&&(console.log("All images have been loaded!"),console.log(this.width,this.height),r.generateMipmap(r.TEXTURE_CUBE_MAP),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),this.refresh())}}class M extends f{constructor(t,i){super(),this.gl=t,this.refresh=i}actualCreate(t){return new P(this.gl,this.refresh,t)}actualDelete(t){t instanceof P&&t.delete()}makeKeyFromInput(t){return t}}class z extends f{constructor(t,i){super(),this.gl=t,this.refresh=i}actualCreate(t){return new U(this.gl,this.refresh,t)}actualDelete(t){t instanceof U&&t.delete()}makeKeyFromInput(t){return t}}class I{constructor(t,i,e){var s,r;this.gl=t;const n=t.createBuffer();if(!n)throw Error("Unable to create WebGLBuffer!");this._target=null!==(s=null==e?void 0:e.target)&&void 0!==s?s:"ARRAY_BUFFER",this._usage=null!==(r=null==e?void 0:e.usage)&&void 0!==r?r:"STATIC_DRAW",this.buffer=n,i&&this.bufferData(i,e)}get target(){return this._target}bind(t){const{gl:i,buffer:e}=this;this._target=null!=t?t:this._target,i.bindBuffer(i[this._target],e)}bufferData(t,i={}){var e;const{gl:s}=this;this.bind(i.target),this._usage=null!==(e=i.usage)&&void 0!==e?e:this._usage,s.bufferData(s[this._target],t,s[this._usage])}delete(){const{gl:t,buffer:i}=this;t.deleteBuffer(i)}}class R{constructor(t,i,e,s){this.gl=t,this.drawBuffers=[],this.elemBuffer=null;const r=t.createVertexArray();if(!r)throw Error("Unable to create VertexArrayObject!");if(this.vao=r,i&&e){if(t.bindVertexArray(r),this.drawBuffers=e.map((e=>{const s=new I(t,e.dataView,{target:e.target,usage:e.usage});return s.bind(),e.defineAttributes(t,i),s})),s){const i=new I(t,s,{target:"ELEMENT_ARRAY_BUFFER"});i.bind(),this.elemBuffer=i}t.bindVertexArray(null)}}bind(){this.gl.bindVertexArray(this.vao)}unbind(){this.gl.bindVertexArray(null)}delete(){const{gl:t,vao:i,drawBuffers:e,elemBuffer:s}=this;t.deleteVertexArray(i),e.forEach((t=>t.delete())),s&&s.delete()}}class X{constructor(t,i={}){var e;this.canvas=t,this.painters=new g,this.isPlaying=!1,this.requestAnimationFrame=-1,this.lastTime=-1,this.paint=()=>{window.cancelAnimationFrame(this.requestAnimationFrame),this.requestAnimationFrame=window.requestAnimationFrame(this.actualPaint)},this.actualPaint=t=>{const{lastTime:i}=this;if(i<0)return this.lastTime=t,void this.paint();const e=t-this.lastTime;this.lastTime=t,this.painters.paint(t,e),this.painters.update(t,e),this.isPlaying&&this.paint()};const s=t.getContext("webgl2",i);if(!s)throw Error("Unable to create a WebGL2 context!");this.gl=s,this.programs=new b(s),this.textures2D=new M(s,this.paint),this.texturesCube=new z(s,this.paint);const r=null!==(e=i.onResize)&&void 0!==e?e:Y;this.observer=new ResizeObserver((()=>{r(s,t.clientWidth,t.clientHeight)})),this.observer.observe(t)}get width(){return this.gl.drawingBufferWidth}get height(){return this.gl.drawingBufferHeight}get playing(){return this.isPlaying}set playing(t){t!==this.isPlaying&&(t&&this.paint(),this.isPlaying=t)}play(){this.playing=!0}pause(){this.playing=!1}add(...t){this.painters.add(...t)}remove(...t){this.painters.remove(...t)}createBuffer(t,i){return new I(this.gl,t,i)}createVAO(t,i,e){return new R(this.gl,t,i,e)}destroy(){window.cancelAnimationFrame(this.requestAnimationFrame),this.playing=!1,this.painters.delete(),this.observer.unobserve(this.canvas)}}function Y(t,i,e){const s=t.canvas;s.width=i,s.height=e,t.viewport(0,0,i,e)}class L{constructor(){this.keysDown=new Set,this.keysUp=new Set,this.attached=!1,this.handleKeyDown=t=>{this.keysDown.add(t.key),this.keysUp.delete(t.key)},this.handleKeyUp=t=>{this.keysDown.delete(t.key),this.keysUp.add(t.key)},document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp),this.attached=!0}detach(){this.attached&&(document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.attached=!1)}isPressed(...t){for(const i of t)if(!this.keysDown.has(i))return!1;return!0}hasClicked(t){return!!this.keysUp.has(t)&&(this.keysUp.delete(t),!0)}}class N{constructor(t){var i;this.options=t,this.start={x:0,y:0,t:0},this.current={x:0,y:0,t:0},this.previous={x:0,y:0,t:0},this.canvas=null,this.active=!1,this.canvasX=0,this.canvasY=0,this.screenX=0,this.screenY=0,this.inertiaDirX=0,this.inertiaDirY=0,this.inertiaStart=0,this.inertiaStop=!0,this.inertiaRunning=!1,this.inertiaTimeStamp=0,this.inertiaLastRefresh=0,this.handleCanvasWheel=t=>{const{onZoom:i}=this.options;i&&i(t.deltaY,(()=>t.preventDefault()))},this.handleCanvasPointerDown=t=>{t.isPrimary&&(this.canvasX=t.clientX,this.canvasY=t.clientY,this.active=!0,this.inertiaStop=!0)},this.handlePointerDown=t=>{var i,e;if(!t.isPrimary||!this.active)return;this.screenX=t.clientX,this.screenY=t.clientY;const s=this.getPoint(t);this.start=this.current=s,null===(e=(i=this.options).onMoveStart)||void 0===e||e.call(i,s)},this.handlePointerMove=t=>{var i,e;t.isPrimary&&this.active&&this.canvas&&(this.previous=this.current,this.current=this.getPoint(t),null===(e=(i=this.options).onMove)||void 0===e||e.call(i,this))},this.handlePointerUp=t=>{var i,e;if(!t.isPrimary||!this.active)return;this.current=this.getPoint(t),null===(e=(i=this.options).onMoveEnd)||void 0===e||e.call(i,this.current),this.active=!1,this.inertiaStart=t.timeStamp,this.inertiaStop=!1,this.inertiaRunning=!1;const s=this.current.t-this.previous.t,r=s>0?1/s:0;this.inertiaDirX=r*(this.current.x-this.previous.x),this.inertiaDirY=r*(this.current.y-this.previous.y),window.requestAnimationFrame(this.simulateInertia)},this.simulateInertia=t=>{const{onMove:i}=this.options;if(!i||this.inertiaDuration<=0)return;if(this.inertiaStop)return;this.inertiaRunning||(this.inertiaTimeStamp=t,this.inertiaLastRefresh=t,this.inertiaRunning=!0);const e=t-this.inertiaTimeStamp,s=1-e/this.inertiaDuration;if(s<=0||s>1)return;const r=e-this.inertiaLastRefresh;this.inertiaLastRefresh=e;const n=this.inertiaDirX*r*s,h=this.inertiaDirY*r*s;this.previous=Object.assign({},this.current),this.current.t=this.previous.t+r,this.current.x+=n,this.current.y+=h;const{current:o,previous:a,start:c}=this;i({current:o,previous:a,start:c}),window.requestAnimationFrame(this.simulateInertia)},this.inertiaDuration=null!==(i=t.inertia)&&void 0!==i?i:0,t.canvas&&this.attach(t.canvas)}get element(){return this.canvas}attach(t){this.detach(),this.canvas=t,t.addEventListener("pointerdown",this.handleCanvasPointerDown,!0),t.addEventListener("wheel",this.handleCanvasWheel),document.addEventListener("pointerdown",this.handlePointerDown),document.addEventListener("pointermove",this.handlePointerMove),document.addEventListener("pointerup",this.handlePointerUp)}detach(){const{canvas:t}=this;t&&(t.removeEventListener("pointerdown",this.handleCanvasPointerDown),t.removeEventListener("wheel",this.handleCanvasWheel),document.removeEventListener("pointerdown",this.handlePointerDown),document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerup",this.handlePointerUp),this.canvas=null)}getPoint(t){if(!this.canvas)throw Error("No canvas has been defined!");const{left:i,top:e,width:s,height:r}=this.canvas.getBoundingClientRect();return{x:2*((this.canvasX+t.clientX-this.screenX-i)/s-.5),y:-2*((this.canvasY+t.clientY-this.screenY-e)/r-.5),t:t.timeStamp}}}class S{constructor(t,i={}){this.camera=t,this.pointer=null,this.keyboard=new L,this.handleMove=t=>{const{camera:i,keyboard:e}=this;if(t.current.t-t.previous.t<=0)return;if(e.isPressed("z")){const e=t.previous.x,s=t.previous.y;if(Math.abs(e)+Math.abs(s)===0)return;const r=t.current.x,n=t.current.y;if(Math.abs(r)+Math.abs(n)===0)return;const h=e*r+s*n,o=e*n-s*r,a=Math.atan2(o,h);return void i.orbitAroundZ(-a)}const s=2*(t.current.x-t.previous.x),r=2*(t.current.y-t.previous.y);e.isPressed("x")||i.orbitAroundY(-s),e.isPressed("y")||i.orbitAroundX(r)},this.handleZoom=(t,i)=>{const{camera:e}=this,s=.001*-t;e.zoom=Math.max(1,e.zoom+s),i()},this.options=Object.assign({inertia:500},i)}attach(t){this.pointer&&this.pointer.detach(),this.pointer=new N({canvas:t,onMove:this.handleMove,onZoom:this.handleZoom,inertia:this.options.inertia})}detach(){this.pointer&&(this.pointer.detach(),this.pointer=null)}}class D{constructor(t,i={}){var e,s,r;this.data=null,this.count=0,this.target=null!==(e=i.target)&&void 0!==e?e:"ARRAY_BUFFER",this.usage=null!==(s=i.usage)&&void 0!==s?s:"STATIC_DRAW";const n=null!==(r=i.divisor)&&void 0!==r?r:0;let h=0;const o={},a={};for(const i of Object.keys(t)){const e=i;o[i]=new ArrayBuffer(0);const s={dimension:j[t[e]],bytesOffset:h,bytesPerElement:Float32Array.BYTES_PER_ELEMENT,divisor:n,getter:(t,i)=>(i>=t.byteLength&&(i%=t.byteLength),t.getFloat32(i)),setter(t,i,e){t.setFloat32(i,e)}};a[i]=s,h+=s.bytesPerElement*s.dimension}this.dataPerAttribute=o,this.definitions=a,this.stride=h}set(t,i){var e;if((e=i)&&"object"==typeof e&&i.buffer instanceof ArrayBuffer&&(i=i.buffer),this.dataPerAttribute[t]===i)return;this.dataPerAttribute[t]=i;const{bytesPerElement:s,dimension:r}=this.definitions[t];this.count=Math.max(this.count,Math.ceil(i.byteLength/(s*r))),this.data=null}get dataView(){if(!this.data){const t=new ArrayBuffer(this.stride*this.count),i=new DataView(t);let e=0;const{dataPerAttribute:s,definitions:r}=this;for(let t=0;t<this.count;t++)for(const n of Object.keys(r)){const h=r[n],o=s[n],a=new DataView(o);let c=h.bytesPerElement*h.dimension*t;for(let t=0;t<h.dimension;t++)h.setter(i,e,h.getter(a,c)),c+=h.bytesPerElement,e+=h.bytesPerElement}this.data=new DataView(t)}return this.data}defineAttributes(t,i){let e=0;const{definitions:s}=this;for(const r of Object.keys(s)){const n=s[r],h=i.getAttribLocation(r);t.enableVertexAttribArray(h),t.vertexAttribPointer(h,n.dimension,t.FLOAT,!1,this.stride,e),t.vertexAttribDivisor(h,n.divisor),e+=n.dimension*n.bytesPerElement}}}const j={float:1,vec2:2,vec3:3,vec4:4};class Z{}class F{constructor(t,i,{x:e=0,y:s=0,z:r=1,zoom:n=1}={}){this.context=t,this.zoom=1,this.x=0,this.y=0,this.z=1,this.x=e,this.y=s,this.z=r,this.zoom=n,this.texture=i,this.program=t.programs.create({vert:"#version 300 es\n\nuniform float uniZoom;\nuniform vec2 uniScale;\nuniform vec2 uniScroll;\nuniform float uniZ;\nin vec2 attPoint;\nin vec2 attUV;\nout vec2 varUV;\n\nvoid main() {\n varUV = (attUV + uniScroll) * uniZoom;\n float x = uniScale.x * attPoint.x;\n float y = uniScale.y * attPoint.y;\n gl_Position = vec4(x, y, uniZ, 1.0);\n}",frag:"#version 300 es\n\nprecision mediump float;\n\nuniform sampler2D uniTexture;\nin vec2 varUV;\nout vec4 FragColor;\n\nvoid main() {\n FragColor = texture(uniTexture, varUV);\n}"});const h=new D({attPoint:"vec2",attUV:"vec2"});h.set("attPoint",new Float32Array([-1,1,1,1,-1,-1,1,-1])),h.set("attUV",new Float32Array([0,0,1,0,0,1,1,1])),this.vao=t.createVAO(this.program,[h])}delete(){const{vao:t}=this;t.delete}paint(t,i){const{gl:e}=this.context,{vao:s,program:r,texture:n,zoom:h,x:o,y:a,z:c}=this;r.use();const{width:u,height:m}=this.context,l=n.width*m>n.height*u,d=l?n.width*m/(u*n.height):1,g=l?1:n.height*u/(m*n.width);r.uniform2f("uniScale",d,g),r.uniform2f("uniScroll",o,a),r.uniform1f("uniZoom",1/h),r.uniform1f("uniZ",c),n.activate(r,"uniTexture"),s.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4)}update(t,i){}}class V{constructor(t,i={}){var e,s;this.context=t,this.clearMask=0,this.red=1,this.green=.7,this.blue=0,this.alpha=1,this.depth=1;const{gl:r}=t,n=null!==(e=i.color)&&void 0!==e?e:[0,0,0,1],h=null!==(s=i.depth)&&void 0!==s?s:1;this.clearMask=0;let o=!1;if(i.color&&(this.clearMask|=r.COLOR_BUFFER_BIT,o=!0),"number"==typeof i.depth&&(this.clearMask|=r.DEPTH_BUFFER_BIT,o=!0),!o)throw Error("[TgdPainterClear] You must give at least a color or a depth in the constructor!");[this.red,this.green,this.blue,this.alpha]=n,this.depth=h}delete(){}paint(t,i){const{clearMask:e,context:s,red:r,green:n,blue:h,alpha:o,depth:a}=this,{gl:c}=s;c.clearColor(r,n,h,o),c.clearDepth(a),c.clear(e)}update(t,i){}}class C{constructor(t){this.logicFunction=t}delete(){}paint(t,i){}update(t,i){this.logicFunction(t,i)}}class O{constructor(t,i){this.context=t,this.matrix=new r,this.tmpMat=new r,this.camera=i.camera,this.texture=t.texturesCube.create(i),this.program=t.programs.create({vert:"#version 300 es\n\nin vec4 attPoint;\n\nout vec4 varPoint;\n\nvoid main() {\n varPoint = attPoint;\n gl_Position = vec4(attPoint.xy, 0.999, 1.0);\n}",frag:"#version 300 es\n\nprecision highp float;\n\nuniform samplerCube uniTexture;\nuniform mat4 uniMatrix;\n\nin vec4 varPoint;\n\nout vec4 FragColor;\n\nvoid main() {\n vec4 t = uniMatrix * varPoint;\n FragColor = texture(uniTexture, normalize(t.xyz / t.w));\n}"});const e=new D({attPoint:"vec2"});e.set("attPoint",new Float32Array([-1,1,1,1,-1,-1,1,-1])),this.vao=t.createVAO(this.program,[e])}delete(){const{vao:t}=this;t.delete}paint(t,i){const{gl:e}=this.context,{vao:s,program:r,texture:n}=this;e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.depthRange(0,1),r.use(),r.uniformMatrix4fv("uniMatrix",this.matrix),n.activate(r,"uniTexture"),s.bind(),e.drawArrays(e.TRIANGLE_STRIP,0,4)}update(t,i){const{camera:e,matrix:s,tmpMat:r}=this;s.from(e.matrixProjection),r.fromMat3(e.matrixViewModel),r.m30=0,r.m31=0,r.m32=0,r.m33=1,r.m03=0,r.m13=0,r.m23=0,s.multiply(r).invert()}}class k{constructor(){this.name="Mesh",this.attPosition=[],this.attNormal=[],this.attUV=[],this.elements=[],this.elementIndex=0,this.vertices=[],this.normals=[],this.uvs=[],this.map=new Map,this.onObject=t=>{this.name=t},this.onVertex=(t,i,e)=>{this.vertices.push([t,i,e])},this.onNormal=(t,i,e)=>{this.normals.push([t,i,e])},this.onTexture=(t,i)=>{this.uvs.push([t,i])},this.onFace=t=>{if(3!==t.length)throw Error("We can only deal with triangles!");t.forEach((t=>this.elements.push(this.getElem(t))))}}parse(t){this.reset();const{onVertex:i,onNormal:e,onTexture:s,onFace:r,onObject:n,name:h,elements:o}=this;!function(t,i={}){const{onVertex:e,onNormal:s,onTexture:r,onFace:n,onObject:h}=i;for(const i of function*(t){const i=t.length;let e=0,s=0;for(;e>-1&&e<i&&(e=t.indexOf("\n",s),!(e<0));)yield t.substring(s,e).trim(),s=e+1;return t.substring(s).trim()}(t)){const t=i.trimStart();if(e&&t.startsWith("v ")){const i=t.substring(2).split(" ").map((t=>Number(t)));B(i)&&e(...i)}else if(n&&t.startsWith("f "))n(t.substring(2).split(" ").map((t=>{const[i,e,s]=t.split("/");return{vertex:Number(i)-1,normal:s?Number(s)-1:void 0,uv:e?Number(e)-1:void 0}})));else if(s&&t.startsWith("vn ")){const i=t.substring(3).split(" ").map((t=>Number(t)));B(i)&&s(...i)}else if(r&&t.startsWith("vt ")){const[i,e,s]=t.substring(3).split(" ").map((t=>Number(t)));r(i,e,s)}else h&&t.startsWith("o ")&&h(t.substring(2))}}(t,{onVertex:i,onNormal:e,onTexture:s,onFace:r,onObject:n});const a={name:h,count:Math.floor(o.length/3),attPosition:new Float32Array(this.attPosition)};this.attNormal.length>0&&(a.attNormal=new Float32Array(this.attNormal)),this.attUV.length>0&&(a.attUV=new Float32Array(this.attUV)),console.log("🚀 [wavefront] this.attUV = ",this.attUV);const{elementIndex:c}=this;return c<=256?(console.log("UNSIGNED_BYTE"),Object.assign(Object.assign({},a),{type:"UNSIGNED_BYTE",elements:new Uint8Array(o)})):c<=65536?(console.log("UNSIGNED_SHORT"),Object.assign(Object.assign({},a),{type:"UNSIGNED_SHORT",elements:new Uint16Array(o)})):(console.log("UNSIGNED_INT"),Object.assign(Object.assign({},a),{type:"UNSIGNED_INT",elements:new Uint32Array(o)}))}reset(){this.name="Mesh",this.attPosition=[],this.attNormal=[],this.attUV=[],this.elements=[],this.elementIndex=0,this.vertices=[],this.normals=[],this.uvs=[],this.map.clear()}getElem(t){var i;const e=this.key(t),s=null!==(i=this.map.get(e))&&void 0!==i?i:-1;if(s>-1)return s;const[r,n,h]=this.vertices[t.vertex];if(this.attPosition.push(r,n,h),"number"==typeof t.normal){const[i,e,s]=this.normals[t.normal];this.attNormal.push(i,e,s)}if("number"==typeof t.uv){const[i,e]=this.uvs[t.uv];this.attUV.push(i,e)}return this.map.set(e,this.elementIndex),this.elementIndex++}key(t){return`${t.vertex}/${t.normal}`}}function B(t){return 3===t.length}var W=i.Uj,G=i.w1,$=i.$M,q=i.aT,H=i.OY,K=i.yr,Q=i.Zc,J=i.tz,tt=i.Yp,it=i.Wk,et=i.pD,st=i.WM,rt=i.Op,nt=i.ui,ht=i.ts,ot=i.sh,at=i.a7,ct=i.EK,ut=i.cX,mt=i.qG,lt=i.Ui,dt=i.YE,gt=i.Zk;export{W as TdgInputKeyboard,G as TdgResourceTexture2D,$ as TdgResourceTextureCube,q as TgdCamera,H as TgdCameraOrthographic,K as TgdCameraPerspective,Q as TgdContext,J as TgdControllerCameraOrbit,tt as TgdDataset,it as TgdMat4,et as TgdPainter,st as TgdPainterBackground,rt as TgdPainterClear,nt as TgdPainterGroup,ht as TgdPainterLogic,ot as TgdPainterSkybox,at as TgdParserMeshWavefront,ct as TgdQuat,ut as TgdResource,mt as TgdResourceProgram,lt as TgdVec3,dt as TgdVec4,gt as TgdVertexArray};
|
|
1
|
+
export * from "./camera/index.js";
|
|
2
|
+
export * from "./canvas/index.js";
|
|
3
|
+
export * from "./color/index.js";
|
|
4
|
+
export * from "./context/index.js";
|
|
5
|
+
export * from "./controller/index.js";
|
|
6
|
+
export * from "./dataset/index.js";
|
|
7
|
+
export * from "./event/index.js";
|
|
8
|
+
export * from "./filter/index.js";
|
|
9
|
+
export * from "./geometry/index.js";
|
|
10
|
+
export * from "./input/index.js";
|
|
11
|
+
export * from "./light/index.js";
|
|
12
|
+
export * from "./material/index.js";
|
|
13
|
+
export * from "./math/index.js";
|
|
14
|
+
export * from "./painter/index.js";
|
|
15
|
+
export * from "./painter/painter.js";
|
|
16
|
+
export * from "./parser/index.js";
|
|
17
|
+
export * from "./resource/index.js";
|
|
18
|
+
export * from "./utils/index.js";
|
|
19
|
+
export * from "./vao/index.js";
|
|
20
|
+
export * from "./types/index.js";
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxVQUFVLENBQUE7QUFDeEIsY0FBYyxVQUFVLENBQUE7QUFDeEIsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxXQUFXLENBQUE7QUFDekIsY0FBYyxjQUFjLENBQUE7QUFDNUIsY0FBYyxXQUFXLENBQUE7QUFDekIsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxVQUFVLENBQUE7QUFDeEIsY0FBYyxZQUFZLENBQUE7QUFDMUIsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxTQUFTLENBQUE7QUFDdkIsY0FBYyxZQUFZLENBQUE7QUFDMUIsY0FBYyxRQUFRLENBQUE7QUFDdEIsY0FBYyxXQUFXLENBQUE7QUFDekIsY0FBYyxtQkFBbUIsQ0FBQTtBQUNqQyxjQUFjLFVBQVUsQ0FBQTtBQUN4QixjQUFjLFlBQVksQ0FBQTtBQUMxQixjQUFjLFNBQVMsQ0FBQTtBQUN2QixjQUFjLE9BQU8sQ0FBQTtBQUVyQixjQUFjLFNBQVMsQ0FBQSJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/input/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./inputs.js";
|
|
2
|
+
export * from "./keyboard.js";
|
|
3
|
+
export * from "./pointer.js";
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5wdXQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxVQUFVLENBQUE7QUFDeEIsY0FBYyxZQUFZLENBQUE7QUFDMUIsY0FBYyxXQUFXLENBQUEifQ==
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TgdInputKeyboard } from "../types/input-keyboard";
|
|
2
|
+
import { TgdInputPointer } from "../types/input-pointer";
|
|
3
|
+
export declare class TgdInputs {
|
|
4
|
+
private readonly canvas;
|
|
5
|
+
private _keyboard;
|
|
6
|
+
private _pointer;
|
|
7
|
+
constructor(canvas: HTMLCanvasElement);
|
|
8
|
+
get keyboard(): TgdInputKeyboard;
|
|
9
|
+
get pointer(): TgdInputPointer;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/input/inputs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,qBAAa,SAAS;IAIN,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,QAAQ,CAA+B;gBAElB,MAAM,EAAE,iBAAiB;IAEtD,IAAI,QAAQ,IAAI,gBAAgB,CAK/B;IAED,IAAI,OAAO,IAAI,eAAe,CAK7B;CACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TgdInputKeyboardImpl } from "./keyboard.js";
|
|
2
|
+
import { TgdInputPointerImpl } from "./pointer.js";
|
|
3
|
+
export class TgdInputs {
|
|
4
|
+
canvas;
|
|
5
|
+
_keyboard = null;
|
|
6
|
+
_pointer = null;
|
|
7
|
+
constructor(canvas) {
|
|
8
|
+
this.canvas = canvas;
|
|
9
|
+
}
|
|
10
|
+
get keyboard() {
|
|
11
|
+
if (!this._keyboard) {
|
|
12
|
+
this._keyboard = new TgdInputKeyboardImpl();
|
|
13
|
+
}
|
|
14
|
+
return this._keyboard;
|
|
15
|
+
}
|
|
16
|
+
get pointer() {
|
|
17
|
+
if (!this._pointer) {
|
|
18
|
+
this._pointer = new TgdInputPointerImpl(this.canvas);
|
|
19
|
+
}
|
|
20
|
+
return this._pointer;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2lucHV0L2lucHV0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsb0JBQW9CLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQTtBQUMxRCxPQUFPLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQTtBQUl4RCxNQUFNLE9BQU8sU0FBUztJQUlXO0lBSHJCLFNBQVMsR0FBNEIsSUFBSSxDQUFBO0lBQ3pDLFFBQVEsR0FBMkIsSUFBSSxDQUFBO0lBRS9DLFlBQTZCLE1BQXlCO1FBQXpCLFdBQU0sR0FBTixNQUFNLENBQW1CO0lBQUcsQ0FBQztJQUUxRCxJQUFJLFFBQVE7UUFDUixJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBRSxDQUFDO1lBQ2xCLElBQUksQ0FBQyxTQUFTLEdBQUcsSUFBSSxvQkFBb0IsRUFBRSxDQUFBO1FBQy9DLENBQUM7UUFDRCxPQUFPLElBQUksQ0FBQyxTQUFTLENBQUE7SUFDekIsQ0FBQztJQUVELElBQUksT0FBTztRQUNQLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUSxFQUFFLENBQUM7WUFDakIsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLG1CQUFtQixDQUFDLElBQUksQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUN4RCxDQUFDO1FBQ0QsT0FBTyxJQUFJLENBQUMsUUFBUSxDQUFBO0lBQ3hCLENBQUM7Q0FDSiJ9
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { TgdInputKeyboard } from "../types/input-keyboard";
|
|
2
|
+
import { TgdEvent } from "../event";
|
|
3
|
+
export declare class TgdInputKeyboardImpl implements TgdInputKeyboard {
|
|
4
|
+
readonly eventKeyPress: TgdEvent<KeyboardEvent>;
|
|
2
5
|
private readonly keysDown;
|
|
3
6
|
private readonly keysUp;
|
|
4
7
|
private attached;
|
|
5
8
|
constructor();
|
|
6
9
|
detach(): void;
|
|
7
|
-
|
|
10
|
+
isUp(...keys: string[]): boolean;
|
|
11
|
+
isDown(...keys: string[]): boolean;
|
|
8
12
|
hasClicked(key: string): boolean;
|
|
9
13
|
private readonly handleKeyDown;
|
|
10
14
|
private readonly handleKeyUp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/input/keyboard.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"keyboard.d.ts","sourceRoot":"","sources":["../../src/input/keyboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,qBAAa,oBAAqB,YAAW,gBAAgB;IACzD,SAAgB,aAAa,0BAAgC;IAE7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAQ;;IAQxB,MAAM;IAQN,IAAI,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAIhC,MAAM,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO;IAOlC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAQhC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG7B;IAED,OAAO,CAAC,QAAQ,CAAC,WAAW,CAI3B;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TgdEvent } from "../event/index.js";
|
|
2
|
+
export class TgdInputKeyboardImpl {
|
|
3
|
+
eventKeyPress = new TgdEvent();
|
|
4
|
+
keysDown = new Set();
|
|
5
|
+
keysUp = new Set();
|
|
6
|
+
attached = false;
|
|
7
|
+
constructor() {
|
|
8
|
+
document.addEventListener("keydown", this.handleKeyDown);
|
|
9
|
+
document.addEventListener("keyup", this.handleKeyUp);
|
|
10
|
+
this.attached = true;
|
|
11
|
+
}
|
|
12
|
+
detach() {
|
|
13
|
+
if (!this.attached)
|
|
14
|
+
return;
|
|
15
|
+
document.removeEventListener("keydown", this.handleKeyDown);
|
|
16
|
+
document.removeEventListener("keyup", this.handleKeyUp);
|
|
17
|
+
this.attached = false;
|
|
18
|
+
}
|
|
19
|
+
isUp(...keys) {
|
|
20
|
+
return !this.isDown(...keys);
|
|
21
|
+
}
|
|
22
|
+
isDown(...keys) {
|
|
23
|
+
for (const key of keys) {
|
|
24
|
+
if (!this.keysDown.has(key))
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
hasClicked(key) {
|
|
30
|
+
if (this.keysUp.has(key)) {
|
|
31
|
+
this.keysUp.delete(key);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
handleKeyDown = (evt) => {
|
|
37
|
+
this.keysDown.add(evt.key);
|
|
38
|
+
this.keysUp.delete(evt.key);
|
|
39
|
+
};
|
|
40
|
+
handleKeyUp = (evt) => {
|
|
41
|
+
this.keysDown.delete(evt.key);
|
|
42
|
+
this.keysUp.add(evt.key);
|
|
43
|
+
this.eventKeyPress.dispatch(evt);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia2V5Ym9hcmQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5wdXQva2V5Ym9hcmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLFVBQVUsQ0FBQTtBQUVuQyxNQUFNLE9BQU8sb0JBQW9CO0lBQ2IsYUFBYSxHQUFHLElBQUksUUFBUSxFQUFpQixDQUFBO0lBRTVDLFFBQVEsR0FBRyxJQUFJLEdBQUcsRUFBVSxDQUFBO0lBQzVCLE1BQU0sR0FBRyxJQUFJLEdBQUcsRUFBVSxDQUFBO0lBQ25DLFFBQVEsR0FBRyxLQUFLLENBQUE7SUFFeEI7UUFDSSxRQUFRLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxFQUFFLElBQUksQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUN4RCxRQUFRLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxXQUFXLENBQUMsQ0FBQTtRQUNwRCxJQUFJLENBQUMsUUFBUSxHQUFHLElBQUksQ0FBQTtJQUN4QixDQUFDO0lBRUQsTUFBTTtRQUNGLElBQUksQ0FBQyxJQUFJLENBQUMsUUFBUTtZQUFFLE9BQU07UUFFMUIsUUFBUSxDQUFDLG1CQUFtQixDQUFDLFNBQVMsRUFBRSxJQUFJLENBQUMsYUFBYSxDQUFDLENBQUE7UUFDM0QsUUFBUSxDQUFDLG1CQUFtQixDQ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BQVEsQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQzdCLElBQUksQ0FBQyxNQUFNLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxHQUFHLENBQUMsQ0FBQTtRQUN4QixJQUFJLENBQUMsYUFBYSxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUNwQyxDQUFDLENBQUE7Q0FDSiJ9
|
|
@@ -1,48 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
private inertiaLastRefresh;
|
|
25
|
-
constructor(options: Partial<{
|
|
26
|
-
canvas: HTMLCanvasElement | null;
|
|
27
|
-
onMoveStart: (args: TgdInputPointerEvent) => void;
|
|
28
|
-
onMove: (args: {
|
|
29
|
-
current: TgdInputPointerEvent;
|
|
30
|
-
previous: TgdInputPointerEvent;
|
|
31
|
-
start: TgdInputPointerEvent;
|
|
32
|
-
}) => void;
|
|
33
|
-
onMoveEnd: (args: TgdInputPointerEvent) => void;
|
|
34
|
-
onZoom: (direction: number, preventDefault: () => void) => void;
|
|
35
|
-
inertia: number;
|
|
36
|
-
}>);
|
|
37
|
-
get element(): HTMLCanvasElement | null;
|
|
38
|
-
attach(canvas: HTMLCanvasElement): void;
|
|
1
|
+
import { TgdEvent } from "../event";
|
|
2
|
+
import { TgdInputPointer, TgdInputPointerEventMove, TgdInputPointerEventTap, TgdInputPointerEventZoom } from "../types";
|
|
3
|
+
export declare class TgdInputPointerImpl implements TgdInputPointer {
|
|
4
|
+
private readonly canvas;
|
|
5
|
+
readonly eventTap: TgdEvent<Readonly<TgdInputPointerEventTap>>;
|
|
6
|
+
readonly eventMoveStart: TgdEvent<Readonly<TgdInputPointerEventMove>>;
|
|
7
|
+
readonly eventMove: TgdEvent<Readonly<TgdInputPointerEventMove>>;
|
|
8
|
+
readonly eventMoveEnd: TgdEvent<Readonly<TgdInputPointerEventMove>>;
|
|
9
|
+
readonly eventZoom: TgdEvent<Readonly<TgdInputPointerEventZoom>>;
|
|
10
|
+
/**
|
|
11
|
+
* This is a tap only of the pointer touched for less that
|
|
12
|
+
* `tapDelay` milliseconds.
|
|
13
|
+
*/
|
|
14
|
+
tapDelay: number;
|
|
15
|
+
private controlKeys;
|
|
16
|
+
private start;
|
|
17
|
+
private current;
|
|
18
|
+
private previous;
|
|
19
|
+
/**
|
|
20
|
+
* If not null, the pointer is touching.
|
|
21
|
+
*/
|
|
22
|
+
private pointerEvent;
|
|
23
|
+
constructor(canvas: HTMLCanvasElement);
|
|
39
24
|
detach(): void;
|
|
25
|
+
private readonly handleContextMenu;
|
|
40
26
|
private readonly handleCanvasWheel;
|
|
41
|
-
private readonly handleCanvasPointerDown;
|
|
42
27
|
private readonly handlePointerDown;
|
|
43
28
|
private readonly handlePointerMove;
|
|
44
29
|
private readonly handlePointerUp;
|
|
45
30
|
private getPoint;
|
|
46
|
-
private readonly simulateInertia;
|
|
47
31
|
}
|
|
48
32
|
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/input/pointer.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/input/pointer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EACH,eAAe,EACf,wBAAwB,EAExB,uBAAuB,EACvB,wBAAwB,EAC3B,MAAM,YAAY,CAAA;AAInB,qBAAa,mBAAoB,YAAW,eAAe;IAyC3C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAxCnC,QAAQ,CAAC,QAAQ,8CAAoD;IACrE,QAAQ,CAAC,cAAc,+CAAqD;IAC5E,QAAQ,CAAC,SAAS,+CAAqD;IACvE,QAAQ,CAAC,YAAY,+CAAqD;IAC1E,QAAQ,CAAC,SAAS,+CAAqD;IACvE;;;OAGG;IACI,QAAQ,SAAM;IAErB,OAAO,CAAC,WAAW,CAKlB;IACD,OAAO,CAAC,KAAK,CAKZ;IACD,OAAO,CAAC,OAAO,CAKd;IACD,OAAO,CAAC,QAAQ,CAKf;IACD;;OAEG;IACH,OAAO,CAAC,YAAY,CAA4B;gBAEnB,MAAM,EAAE,iBAAiB;IAQtD,MAAM;IAWN,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAIjC;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAUjC;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAejC;IAED,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAWjC;IAED,OAAO,CAAC,QAAQ,CAAC,eAAe,CAmB/B;IAED,OAAO,CAAC,QAAQ;CAcnB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { TgdEvent } from "./../event/index.js";
|
|
2
|
+
const MOUSE_BUTTON_RIGHT = 2;
|
|
3
|
+
export class TgdInputPointerImpl {
|
|
4
|
+
canvas;
|
|
5
|
+
eventTap = new TgdEvent();
|
|
6
|
+
eventMoveStart = new TgdEvent();
|
|
7
|
+
eventMove = new TgdEvent();
|
|
8
|
+
eventMoveEnd = new TgdEvent();
|
|
9
|
+
eventZoom = new TgdEvent();
|
|
10
|
+
/**
|
|
11
|
+
* This is a tap only of the pointer touched for less that
|
|
12
|
+
* `tapDelay` milliseconds.
|
|
13
|
+
*/
|
|
14
|
+
tapDelay = 300;
|
|
15
|
+
controlKeys = {
|
|
16
|
+
altKey: false,
|
|
17
|
+
ctrlKey: false,
|
|
18
|
+
metaKey: false,
|
|
19
|
+
shiftKey: false,
|
|
20
|
+
};
|
|
21
|
+
start = {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
t: 0,
|
|
25
|
+
fingersCount: 1,
|
|
26
|
+
};
|
|
27
|
+
current = {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0,
|
|
30
|
+
t: 0,
|
|
31
|
+
fingersCount: 1,
|
|
32
|
+
};
|
|
33
|
+
previous = {
|
|
34
|
+
x: 0,
|
|
35
|
+
y: 0,
|
|
36
|
+
t: 0,
|
|
37
|
+
fingersCount: 1,
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* If not null, the pointer is touching.
|
|
41
|
+
*/
|
|
42
|
+
pointerEvent = null;
|
|
43
|
+
constructor(canvas) {
|
|
44
|
+
this.canvas = canvas;
|
|
45
|
+
canvas.addEventListener("pointerdown", this.handlePointerDown, true);
|
|
46
|
+
canvas.addEventListener("wheel", this.handleCanvasWheel);
|
|
47
|
+
canvas.addEventListener("contextmenu", this.handleContextMenu);
|
|
48
|
+
canvas.addEventListener("pointermove", this.handlePointerMove);
|
|
49
|
+
canvas.addEventListener("pointerup", this.handlePointerUp);
|
|
50
|
+
}
|
|
51
|
+
detach() {
|
|
52
|
+
const { canvas } = this;
|
|
53
|
+
if (!canvas)
|
|
54
|
+
return;
|
|
55
|
+
canvas.removeEventListener("pointerdown", this.handlePointerDown);
|
|
56
|
+
canvas.removeEventListener("wheel", this.handleCanvasWheel);
|
|
57
|
+
canvas.removeEventListener("contextmenu", this.handleContextMenu);
|
|
58
|
+
canvas.removeEventListener("pointermove", this.handlePointerMove);
|
|
59
|
+
canvas.removeEventListener("pointerup", this.handlePointerUp);
|
|
60
|
+
}
|
|
61
|
+
handleContextMenu = (evt) => {
|
|
62
|
+
evt.preventDefault();
|
|
63
|
+
};
|
|
64
|
+
handleCanvasWheel = (evt) => {
|
|
65
|
+
let delta = evt.deltaX + evt.deltaY + evt.deltaZ;
|
|
66
|
+
if (delta > 0)
|
|
67
|
+
delta = 1;
|
|
68
|
+
else
|
|
69
|
+
delta = -1;
|
|
70
|
+
this.eventZoom.dispatch({
|
|
71
|
+
current: this.getPoint(evt),
|
|
72
|
+
direction: delta,
|
|
73
|
+
preventDefault: () => evt.preventDefault(),
|
|
74
|
+
...this.controlKeys,
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
handlePointerDown = (evt) => {
|
|
78
|
+
if (!evt.isPrimary)
|
|
79
|
+
return;
|
|
80
|
+
this.canvas.setPointerCapture(evt.pointerId);
|
|
81
|
+
evt.preventDefault();
|
|
82
|
+
evt.stopPropagation();
|
|
83
|
+
this.pointerEvent = evt;
|
|
84
|
+
const point = this.getPoint(evt);
|
|
85
|
+
this.start = this.current = this.previous = point;
|
|
86
|
+
this.eventMoveStart.dispatch({
|
|
87
|
+
start: point,
|
|
88
|
+
current: point,
|
|
89
|
+
previous: point,
|
|
90
|
+
...this.controlKeys,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
handlePointerMove = (evt) => {
|
|
94
|
+
if (!evt.isPrimary || !this.pointerEvent || !this.canvas)
|
|
95
|
+
return;
|
|
96
|
+
this.previous = this.current;
|
|
97
|
+
this.current = this.getPoint(evt);
|
|
98
|
+
this.eventMove.dispatch({
|
|
99
|
+
start: this.start,
|
|
100
|
+
current: this.current,
|
|
101
|
+
previous: this.previous,
|
|
102
|
+
...this.controlKeys,
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
handlePointerUp = (evt) => {
|
|
106
|
+
if (!evt.isPrimary || !this.pointerEvent)
|
|
107
|
+
return;
|
|
108
|
+
evt.preventDefault();
|
|
109
|
+
this.current = this.getPoint(evt);
|
|
110
|
+
this.eventMoveEnd.dispatch({
|
|
111
|
+
start: this.start,
|
|
112
|
+
current: this.current,
|
|
113
|
+
previous: this.previous,
|
|
114
|
+
...this.controlKeys,
|
|
115
|
+
});
|
|
116
|
+
this.pointerEvent = null;
|
|
117
|
+
// Tap event.
|
|
118
|
+
if (evt.timeStamp - this.start.t < this.tapDelay) {
|
|
119
|
+
this.eventTap.dispatch({
|
|
120
|
+
...this.start,
|
|
121
|
+
...this.controlKeys,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
getPoint(evt) {
|
|
126
|
+
this.controlKeys = {
|
|
127
|
+
altKey: evt.altKey || evt.buttons === MOUSE_BUTTON_RIGHT,
|
|
128
|
+
ctrlKey: evt.ctrlKey,
|
|
129
|
+
metaKey: evt.metaKey,
|
|
130
|
+
shiftKey: evt.shiftKey,
|
|
131
|
+
};
|
|
132
|
+
const { left, top, width, height } = this.canvas.getBoundingClientRect();
|
|
133
|
+
const x = 2 * ((evt.clientX - left) / width - 0.5);
|
|
134
|
+
const y = -2 * ((evt.clientY - top) / height - 0.5);
|
|
135
|
+
return { x, y, t: evt.timeStamp, fingersCount: 1 };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicG9pbnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9pbnB1dC9wb2ludGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxZQUFZLENBQUE7QUFTckMsTUFBTSxrQkFBa0IsR0FBRyxDQUFDLENBQUE7QUFFNUIsTUFBTSxPQUFPLG1CQUFtQjtJQXlDQztJQXhDcEIsUUFBUSxHQUFHLElBQUksUUFBUSxFQUFxQyxDQUFBO0lBQzVELGNBQWMsR0FBRyxJQUFJLFFBQVEsRUFBc0MsQ0FBQTtJQUNuRSxTQUFTLEdBQUcsSUFBSSxRQUFRLEVBQXNDLENBQUE7SUFDOUQsWUFBWSxHQUFHLElBQUksUUFBUSxFQUFzQyxDQUFBO0lBQ2pFLFNBQVMsR0FBR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sR0FBRyxHQUFHLENBQUMsQ0FBQTtRQUNuRCxPQUFPLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEVBQUUsR0FBRyxDQUFDLFNBQVMsRUFBRSxZQUFZLEVBQUUsQ0FBQyxFQUFFLENBQUE7SUFDdEQsQ0FBQztDQUNKIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TgdVec3, TgdVec4 } from "../math";
|
|
2
|
+
export interface TgdLightOptions {
|
|
3
|
+
color: TgdVec4;
|
|
4
|
+
direction: TgdVec3;
|
|
5
|
+
}
|
|
6
|
+
export declare class TgdLight {
|
|
7
|
+
/**
|
|
8
|
+
* The alpha channel is the intensity of the light.
|
|
9
|
+
*/
|
|
10
|
+
color: TgdVec4;
|
|
11
|
+
private readonly _direction;
|
|
12
|
+
constructor(options?: Partial<TgdLightOptions>);
|
|
13
|
+
get direction(): TgdVec3;
|
|
14
|
+
set direction(v: TgdVec3);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=light.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../src/light/light.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;CACrB;AAED,qBAAa,QAAQ;IACjB;;OAEG;IACI,KAAK,EAAE,OAAO,CAAA;IAErB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;gBAE/B,OAAO,GAAE,OAAO,CAAC,eAAe,CAAM;IAKlD,IAAI,SAAS,IAGI,OAAO,CADvB;IACD,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,EAEvB;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TgdVec3, TgdVec4 } from "./../math/index.js";
|
|
2
|
+
export class TgdLight {
|
|
3
|
+
/**
|
|
4
|
+
* The alpha channel is the intensity of the light.
|
|
5
|
+
*/
|
|
6
|
+
color;
|
|
7
|
+
_direction = new TgdVec3();
|
|
8
|
+
constructor(options = {}) {
|
|
9
|
+
this.color = options.color ?? new TgdVec4(0.8, 0.8, 0.8, 1);
|
|
10
|
+
this.direction = options.direction ?? new TgdVec3(0, 0, -1);
|
|
11
|
+
}
|
|
12
|
+
get direction() {
|
|
13
|
+
return this._direction;
|
|
14
|
+
}
|
|
15
|
+
set direction(v) {
|
|
16
|
+
this._direction.from(v).normalize();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlnaHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGlnaHQvbGlnaHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxXQUFXLENBQUE7QUFPNUMsTUFBTSxPQUFPLFFBQVE7SUFDakI7O09BRUc7SUFDSSxLQUFLLENBQVM7SUFFSixVQUFVLEdBQUcsSUFBSSxPQUFPLEVBQUUsQ0FBQTtJQUUzQyxZQUFZLFVBQW9DLEVBQUU7UUFDOUMsSUFBSSxDQUFDLEtBQUssR0FBRyxPQUFPLENBQUMsS0FBSyxJQUFJLElBQUksT0FBTyxDQUFDLEdBQUcsRUFBRSxHQUFHLEVBQUUsR0FBRyxFQUFFLENBQUMsQ0FBQyxDQUFBO1FBQzNELElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsSUFBSSxJQUFJLE9BQU8sQ0FBQyxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFDL0QsQ0FBQztJQUVELElBQUksU0FBUztRQUNULE9BQU8sSUFBSSxDQUFDLFVBQVUsQ0FBQTtJQUMxQixDQUFDO0lBQ0QsSUFBSSxTQUFTLENBQUMsQ0FBVTtRQUNwQixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxTQUFTLEVBQUUsQ0FBQTtJQUN2QyxDQUFDO0NBQ0oifQ==
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export declare class TgdLoaderImage {
|
|
2
|
+
/**
|
|
3
|
+
* Try to load an image and return `null` in case of failure.
|
|
4
|
+
* @param url URL of the image to load.
|
|
5
|
+
*/
|
|
2
6
|
static image(url: string): Promise<HTMLImageElement | null>;
|
|
3
7
|
static canvas(url: string): Promise<HTMLCanvasElement | null>;
|
|
4
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/loader/image.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/loader/image.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc;IACvB;;;OAGG;WACU,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;WAYpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAatE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export class TgdLoaderImage {
|
|
2
|
+
/**
|
|
3
|
+
* Try to load an image and return `null` in case of failure.
|
|
4
|
+
* @param url URL of the image to load.
|
|
5
|
+
*/
|
|
6
|
+
static async image(url) {
|
|
7
|
+
return new Promise(resolve => {
|
|
8
|
+
const img = new Image();
|
|
9
|
+
img.onload = () => resolve(img);
|
|
10
|
+
img.onerror = () => {
|
|
11
|
+
console.error("Unable to load image: ", url);
|
|
12
|
+
resolve(null);
|
|
13
|
+
};
|
|
14
|
+
img.src = url;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
static async canvas(url) {
|
|
18
|
+
const img = await TgdLoaderImage.image(url);
|
|
19
|
+
if (!img)
|
|
20
|
+
return null;
|
|
21
|
+
const canvas = document.createElement("canvas");
|
|
22
|
+
canvas.width = img.naturalWidth;
|
|
23
|
+
canvas.height = img.naturalHeight;
|
|
24
|
+
const ctx = canvas.getContext("2d");
|
|
25
|
+
if (!ctx)
|
|
26
|
+
throw Error("Unable to get a 2D context!");
|
|
27
|
+
ctx.drawImage(img, 0, 0);
|
|
28
|
+
return canvas;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW1hZ2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbG9hZGVyL2ltYWdlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sT0FBTyxjQUFjO0lBQ3ZCOzs7T0FHRztJQUNILE1BQU0sQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLEdBQVc7UUFDMUIsT0FBTyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRTtZQUN6QixNQUFNLEdBQUcsR0FBRyxJQUFJLEtBQUssRUFBRSxDQUFBO1lBQ3ZCLEdBQUcsQ0FBQyxNQUFNLEdBQUcsR0FBRyxFQUFFLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQy9CLEdBQUcsQ0FBQyxPQUFPLEdBQUcsR0FBRyxFQUFFO2dCQUNmLE9BQU8sQ0FBQyxLQUFLLENBQUMsd0JBQXdCLEVBQUUsR0FBRyxDQUFDLENBQUE7Z0JBQzVDLE9BQU8sQ0FBQyxJ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