chorama 0.0.0
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/.configs/tsconfig.lib.json +43 -0
- package/.configs/tsconfig.website.json +34 -0
- package/.github/workflows/static.yml +88 -0
- package/.vscode/launch.json +29 -0
- package/.vscode/tasks.json +19 -0
- package/README.md +127 -0
- package/assets/images/disappointed.jpg +0 -0
- package/assets/images/skybox/grimmnight_back.png +0 -0
- package/assets/images/skybox/grimmnight_bottom.png +0 -0
- package/assets/images/skybox/grimmnight_front.png +0 -0
- package/assets/images/skybox/grimmnight_left.png +0 -0
- package/assets/images/skybox/grimmnight_right.png +0 -0
- package/assets/images/skybox/grimmnight_top.png +0 -0
- package/assets/images/skybox/miramar_back.png +0 -0
- package/assets/images/skybox/miramar_bottom.png +0 -0
- package/assets/images/skybox/miramar_front.png +0 -0
- package/assets/images/skybox/miramar_left.png +0 -0
- package/assets/images/skybox/miramar_right.png +0 -0
- package/assets/images/skybox/miramar_top.png +0 -0
- package/assets/images/uv.jpg +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_BaseColor.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_Normal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_GlassPlasticMat_OcclusionRoughMetal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_BaseColor.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_Normal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LeatherPartsMat_OcclusionRoughMetal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_BaseColor.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_Normal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_BaseColor.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_Normal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_MetalPartsMat_OcclusionRoughMetal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_BaseColor.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_Normal.png +0 -0
- package/assets/models/gltf/flight_helmet/FlightHelmet_Materials_RubberWoodMat_OcclusionRoughMetal.png +0 -0
- package/assets/models/gltf/flight_helmet/index.bin +0 -0
- package/assets/models/gltf/flight_helmet/index.gltf +705 -0
- package/assets/models/gltf/object.gltf +23 -0
- package/assets/models/gltf/pirate_girl/index.bin +0 -0
- package/assets/models/gltf/pirate_girl/index.gltf +2082 -0
- package/assets/models/obj/pirate_girl/pirate_girl.obj +18459 -0
- package/assets/models/obj/pirate_girl/pirate_girl.png +0 -0
- package/astro.config.mjs +45 -0
- package/content/guide/api-map.md +89 -0
- package/content/guide/camera-and-controls.md +98 -0
- package/content/guide/first-scene.md +176 -0
- package/content/guide/index.md +72 -0
- package/content/guide/installation.md +179 -0
- package/content/guide/materials-and-lighting.md +138 -0
- package/content/guide/plugins-and-render-pipeline.md +124 -0
- package/content/guide/render-targets-and-views.md +147 -0
- package/content/guide/scene-graph-and-transforms.md +113 -0
- package/content/guide/textures-and-assets.md +120 -0
- package/content/guide/troubleshooting.md +49 -0
- package/env.d.ts +19 -0
- package/examples/addons/rendergraph_gui.js +580 -0
- package/examples/camera/orthographic.js +120 -0
- package/examples/camera/perspective.js +138 -0
- package/examples/lights/directional.js +397 -0
- package/examples/lights/multiple_spot_lights.js +304 -0
- package/examples/lights/point.js +337 -0
- package/examples/lights/spot.js +366 -0
- package/examples/loader/gltf_material.js +111 -0
- package/examples/loader/gltfloader.js +78 -0
- package/examples/loader/objloader.js +95 -0
- package/examples/material/cullface.js +111 -0
- package/examples/material/materials.js +126 -0
- package/examples/material/standard/basic.js +164 -0
- package/examples/mesh/circle.js +117 -0
- package/examples/mesh/cuboid.js +151 -0
- package/examples/mesh/cylinder.js +139 -0
- package/examples/mesh/geometries.js +108 -0
- package/examples/mesh/meshTopology.js +103 -0
- package/examples/mesh/plane.js +117 -0
- package/examples/mesh/skinning.js +136 -0
- package/examples/mesh/uvsphere.js +113 -0
- package/examples/other/rotatingCube.js +93 -0
- package/examples/other/rotatingSphere.js +96 -0
- package/examples/rendertarget/basic_canvas.js +130 -0
- package/examples/rendertarget/depth_texture.js +130 -0
- package/examples/rendertarget/image_target.js +140 -0
- package/examples/rendertarget/multiple_views.js +158 -0
- package/examples/rendertarget/render_masks.js +173 -0
- package/examples/rendertarget/split_screen.js +123 -0
- package/examples/rendertarget/split_view.js +137 -0
- package/examples/skybox/skybox.js +111 -0
- package/examples/texture/arrays.js +156 -0
- package/examples/texture/textureWrap.js +118 -0
- package/examples/transform/propagation.js +92 -0
- package/package.json +55 -0
- package/rollup.config.js +66 -0
- package/scripts/stage-chorama.mjs +29 -0
- package/src/caches/cache.js +420 -0
- package/src/caches/index.js +2 -0
- package/src/caches/uniformbuffers.js +104 -0
- package/src/cameracontrols/index.js +258 -0
- package/src/constants/index.js +3 -0
- package/src/constants/mesh.js +197 -0
- package/src/constants/others.js +218 -0
- package/src/constants/texture.js +183 -0
- package/src/core/constants.js +14 -0
- package/src/core/extensions.js +42 -0
- package/src/core/index.js +7 -0
- package/src/core/layouts/index.js +4 -0
- package/src/core/layouts/meshvertex.js +60 -0
- package/src/core/layouts/uniform.js +21 -0
- package/src/core/layouts/uniformbuffer.js +15 -0
- package/src/core/layouts/vertexbuffer.js +43 -0
- package/src/core/limits.js +247 -0
- package/src/core/resources/blendparams.js +89 -0
- package/src/core/resources/framebuffer.js +127 -0
- package/src/core/resources/gpubuffer.js +32 -0
- package/src/core/resources/gpumesh.js +43 -0
- package/src/core/resources/gputexture.js +73 -0
- package/src/core/resources/index.js +5 -0
- package/src/core/shader.js +62 -0
- package/src/core/webgl/bindgroup.js +89 -0
- package/src/core/webgl/descriptors.js +104 -0
- package/src/core/webgl/index.js +5 -0
- package/src/core/webgl/renderpassencoder.js +96 -0
- package/src/core/webgl/renderpipeline.js +54 -0
- package/src/core/webgl/utils.js +371 -0
- package/src/core/webgl/webglrenderdevice.js +235 -0
- package/src/function.js +358 -0
- package/src/index.js +15 -0
- package/src/loader/gltf.js +2172 -0
- package/src/loader/index.js +3 -0
- package/src/loader/loader.js +174 -0
- package/src/loader/obj.js +188 -0
- package/src/loader/texture.js +85 -0
- package/src/loader/utils.js +16 -0
- package/src/material/basic.js +75 -0
- package/src/material/depth.js +73 -0
- package/src/material/index.js +8 -0
- package/src/material/lambert.js +73 -0
- package/src/material/material.js +106 -0
- package/src/material/normal.js +30 -0
- package/src/material/phong.js +86 -0
- package/src/material/raw.js +52 -0
- package/src/material/standard.js +221 -0
- package/src/math/index.js +3 -0
- package/src/math/transform.js +38 -0
- package/src/mesh/attribute/attribute.js +79 -0
- package/src/mesh/attribute/index.js +1 -0
- package/src/mesh/attributedata/index.js +1 -0
- package/src/mesh/attributedata/separate.js +180 -0
- package/src/mesh/builders/base.js +41 -0
- package/src/mesh/builders/circle.js +63 -0
- package/src/mesh/builders/cuboid.js +135 -0
- package/src/mesh/builders/cylinder.js +131 -0
- package/src/mesh/builders/index.js +7 -0
- package/src/mesh/builders/plane.js +73 -0
- package/src/mesh/builders/utils.js +20 -0
- package/src/mesh/builders/uvsphere.js +80 -0
- package/src/mesh/builders/wireframe.js +62 -0
- package/src/mesh/index.js +4 -0
- package/src/mesh/mesh.js +149 -0
- package/src/objects/bone.js +17 -0
- package/src/objects/camera/camera.js +56 -0
- package/src/objects/camera/index.js +2 -0
- package/src/objects/camera/projection.js +203 -0
- package/src/objects/debug/index.js +1 -0
- package/src/objects/debug/skeleton.js +28 -0
- package/src/objects/index.js +7 -0
- package/src/objects/light/ambient.js +20 -0
- package/src/objects/light/directional.js +29 -0
- package/src/objects/light/index.js +5 -0
- package/src/objects/light/point.js +32 -0
- package/src/objects/light/shadow/index.js +1 -0
- package/src/objects/light/shadow/shadow.js +67 -0
- package/src/objects/light/spot.js +56 -0
- package/src/objects/mesh.js +141 -0
- package/src/objects/object3d.js +167 -0
- package/src/objects/skybox.js +38 -0
- package/src/plugins/camera/camera.js +19 -0
- package/src/plugins/camera/index.js +2 -0
- package/src/plugins/camera/nodes/cameraview.js +46 -0
- package/src/plugins/camera/nodes/index.js +2 -0
- package/src/plugins/camera/nodes/opaquepass.js +79 -0
- package/src/plugins/index.js +6 -0
- package/src/plugins/light/index.js +2 -0
- package/src/plugins/light/light.js +23 -0
- package/src/plugins/light/nodes/index.js +1 -0
- package/src/plugins/light/nodes/light.js +127 -0
- package/src/plugins/meshmaterial/index.js +3 -0
- package/src/plugins/meshmaterial/meshmaterial.js +381 -0
- package/src/plugins/meshmaterial/nodes/index.js +1 -0
- package/src/plugins/meshmaterial/nodes/meshmaterial.js +50 -0
- package/src/plugins/meshmaterial/resources/index.js +1 -0
- package/src/plugins/meshmaterial/resources/meshmaterialpipelines.js +50 -0
- package/src/plugins/shadow/index.js +3 -0
- package/src/plugins/shadow/nodes/index.js +3 -0
- package/src/plugins/shadow/nodes/shadow.js +272 -0
- package/src/plugins/shadow/nodes/shadowOccluder.js +112 -0
- package/src/plugins/shadow/nodes/shadowOpaquePass.js +73 -0
- package/src/plugins/shadow/resources/ShadowMap.js +99 -0
- package/src/plugins/shadow/resources/index.js +2 -0
- package/src/plugins/shadow/resources/shadowpipelines.js +25 -0
- package/src/plugins/shadow/shadow.js +31 -0
- package/src/plugins/skeletonhelper/index.js +1 -0
- package/src/plugins/skeletonhelper/skeletonhelper.js +160 -0
- package/src/plugins/skybox/index.js +3 -0
- package/src/plugins/skybox/nodes/index.js +1 -0
- package/src/plugins/skybox/nodes/skybox.js +143 -0
- package/src/plugins/skybox/resources/index.js +2 -0
- package/src/plugins/skybox/resources/skyboxmesh.js +14 -0
- package/src/plugins/skybox/resources/skyboxpipeline.js +6 -0
- package/src/plugins/skybox/skybox.js +137 -0
- package/src/renderer/core/index.js +179 -0
- package/src/renderer/graph/index.js +3 -0
- package/src/renderer/graph/nodes.js +34 -0
- package/src/renderer/graph/rendergraph.js +182 -0
- package/src/renderer/index.js +5 -0
- package/src/renderer/plugin.js +36 -0
- package/src/renderer/renderer.js +179 -0
- package/src/renderer/views.js +28 -0
- package/src/rendertarget/canvastarget.js +30 -0
- package/src/rendertarget/image.js +132 -0
- package/src/rendertarget/index.js +3 -0
- package/src/rendertarget/rendertarget.js +89 -0
- package/src/shader/basicFragment.glsl +30 -0
- package/src/shader/basicVertex.glsl +87 -0
- package/src/shader/common/color.glsl +7 -0
- package/src/shader/common/common.glsl +25 -0
- package/src/shader/common/index.js +4 -0
- package/src/shader/common/light.glsl +437 -0
- package/src/shader/common/math.glsl +12 -0
- package/src/shader/debug/index.js +2 -0
- package/src/shader/debug/skeletonFragment.glsl +8 -0
- package/src/shader/debug/skeletonVertex.glsl +27 -0
- package/src/shader/depthFragment.glsl +37 -0
- package/src/shader/index.js +11 -0
- package/src/shader/lambertFragment.glsl +126 -0
- package/src/shader/normalFragment.glsl +25 -0
- package/src/shader/phongFragment.glsl +140 -0
- package/src/shader/skyboxFragment.glsl +16 -0
- package/src/shader/skyboxVertex.glsl +20 -0
- package/src/shader/standardFragment.glsl +274 -0
- package/src/texture/index.js +2 -0
- package/src/texture/sampler.js +111 -0
- package/src/texture/texture.js +234 -0
- package/src/utils/index.js +115 -0
- package/tsconfig.json +11 -0
- package/website/config/index.ts +1 -0
- package/website/config/navigation.ts +53 -0
- package/website/content.config.ts +92 -0
- package/website/layouts/DocLayout.astro +501 -0
- package/website/layouts/Example.astro +91 -0
- package/website/pages/examples/[...slug].astro +77 -0
- package/website/pages/examples/index.astro +98 -0
- package/website/pages/examples/samples/[...slug].astro +17 -0
- package/website/pages/guide/[slug].astro +30 -0
- package/website/pages/guide/index.astro +21 -0
- package/website/pages/index.astro +9 -0
- package/website/plugins/remark-link-base.js +23 -0
- package/website/utils/url.ts +30 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Affine3, clamp, Vector2, Vector3 } from "../math/index.js"
|
|
2
|
+
import { Camera } from "../objects/index.js"
|
|
3
|
+
|
|
4
|
+
export class OrbitCameraControls {
|
|
5
|
+
#targetElement
|
|
6
|
+
#mousedown
|
|
7
|
+
#mouseup
|
|
8
|
+
#mousemove
|
|
9
|
+
#pointercancel
|
|
10
|
+
#wheel
|
|
11
|
+
#contextmenu
|
|
12
|
+
#blur
|
|
13
|
+
elevation = 0
|
|
14
|
+
azimuth = 0
|
|
15
|
+
distance = 5
|
|
16
|
+
minDistance = 0.01
|
|
17
|
+
maxDistance = Infinity
|
|
18
|
+
tideLocked = true
|
|
19
|
+
offset = new Vector3()
|
|
20
|
+
minElevation = -Math.PI / 2
|
|
21
|
+
maxElevation = Math.PI / 2
|
|
22
|
+
sensitivity = 0.02
|
|
23
|
+
moveSensitivity = 0.002
|
|
24
|
+
zoomSensitivity = 0.001
|
|
25
|
+
camera
|
|
26
|
+
/**
|
|
27
|
+
* @type {Set<string>}
|
|
28
|
+
*/
|
|
29
|
+
keys = new Set()
|
|
30
|
+
mousePosition = new Vector2()
|
|
31
|
+
mouseDelta = new Vector2()
|
|
32
|
+
/**
|
|
33
|
+
* @type {Map<number, Vector2>}
|
|
34
|
+
*/
|
|
35
|
+
touchPointers = new Map()
|
|
36
|
+
/**
|
|
37
|
+
* @param {Camera} camera
|
|
38
|
+
*/
|
|
39
|
+
constructor(camera, targetElement = document.body) {
|
|
40
|
+
this.camera = camera
|
|
41
|
+
this.#targetElement = targetElement
|
|
42
|
+
if (targetElement instanceof HTMLElement) {
|
|
43
|
+
targetElement.style.touchAction = 'none'
|
|
44
|
+
}
|
|
45
|
+
this.#mousedown = mouseDown.bind(this)
|
|
46
|
+
this.#mouseup = mouseUp.bind(this)
|
|
47
|
+
this.#mousemove = mousemove.bind(this)
|
|
48
|
+
this.#pointercancel = cancelInput.bind(this)
|
|
49
|
+
this.#wheel = mouseWheel.bind(this)
|
|
50
|
+
this.#contextmenu = (/** @type {MouseEvent} */ e) => e.preventDefault()
|
|
51
|
+
this.#blur = cancelInput.bind(this)
|
|
52
|
+
|
|
53
|
+
targetElement.addEventListener('pointerdown', this.#mousedown)
|
|
54
|
+
targetElement.addEventListener('pointerup', this.#mouseup)
|
|
55
|
+
targetElement.addEventListener('pointermove', this.#mousemove)
|
|
56
|
+
targetElement.addEventListener('pointercancel', this.#pointercancel)
|
|
57
|
+
targetElement.addEventListener('lostpointercapture', this.#pointercancel)
|
|
58
|
+
targetElement.addEventListener('wheel', this.#wheel, { passive: false })
|
|
59
|
+
targetElement.addEventListener('contextmenu', this.#contextmenu)
|
|
60
|
+
window.addEventListener('blur', this.#blur)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
updateOrbit() {
|
|
64
|
+
const { position, orientation } = this.camera.transform
|
|
65
|
+
const { offset: target } = this
|
|
66
|
+
const eye = new Vector3(
|
|
67
|
+
this.distance * Math.sin(this.azimuth) * Math.cos(this.elevation),
|
|
68
|
+
this.distance * Math.sin(this.elevation),
|
|
69
|
+
this.distance * Math.cos(this.azimuth) * Math.cos(this.elevation)
|
|
70
|
+
).add(target)
|
|
71
|
+
const initial = Affine3.lookAt(eye, target, Vector3.Y)
|
|
72
|
+
const [finalPos, finalOrient, _] = initial.decompose()
|
|
73
|
+
|
|
74
|
+
position.x = finalPos.x
|
|
75
|
+
position.y = finalPos.y
|
|
76
|
+
position.z = finalPos.z
|
|
77
|
+
|
|
78
|
+
if (this.tideLocked) {
|
|
79
|
+
orientation.x = finalOrient.x
|
|
80
|
+
orientation.y = finalOrient.y
|
|
81
|
+
orientation.z = finalOrient.z
|
|
82
|
+
orientation.w = finalOrient.w
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
updateInput() {
|
|
87
|
+
const delta = this.mouseDelta
|
|
88
|
+
const input = new Vector2()
|
|
89
|
+
|
|
90
|
+
if (this.keys.has('mouseright')) {
|
|
91
|
+
const temp = Vector2.set(-this.moveSensitivity, -this.moveSensitivity)
|
|
92
|
+
input.add(temp.multiply(delta))
|
|
93
|
+
} else if (this.keys.has('mouseleft')) {
|
|
94
|
+
|
|
95
|
+
this.azimuth += -delta.x * this.sensitivity
|
|
96
|
+
this.elevation += delta.y * this.sensitivity
|
|
97
|
+
this.elevation = clamp(this.elevation, this.minElevation, this.maxElevation)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
Vector2.rotate(input, -this.azimuth, input)
|
|
102
|
+
this.offset.x += input.x
|
|
103
|
+
this.offset.z += input.y
|
|
104
|
+
this.mouseDelta.set(0, 0)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
update() {
|
|
108
|
+
this.updateInput()
|
|
109
|
+
this.updateOrbit()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
dispose(){
|
|
113
|
+
const targetElement = this.#targetElement
|
|
114
|
+
targetElement.removeEventListener('pointerdown', this.#mousedown)
|
|
115
|
+
targetElement.removeEventListener('pointerup', this.#mouseup)
|
|
116
|
+
targetElement.removeEventListener('pointermove', this.#mousemove)
|
|
117
|
+
targetElement.removeEventListener('pointercancel', this.#pointercancel)
|
|
118
|
+
targetElement.removeEventListener('lostpointercapture', this.#pointercancel)
|
|
119
|
+
targetElement.removeEventListener('wheel', this.#wheel)
|
|
120
|
+
targetElement.removeEventListener('contextmenu', this.#contextmenu)
|
|
121
|
+
window.removeEventListener('blur', this.#blur)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @this {OrbitCameraControls}
|
|
127
|
+
* @param {PointerEvent} event
|
|
128
|
+
*/
|
|
129
|
+
function mouseDown(event) {
|
|
130
|
+
event.preventDefault()
|
|
131
|
+
this.mousePosition.set(event.clientX, event.clientY)
|
|
132
|
+
this.mouseDelta.set(0, 0)
|
|
133
|
+
|
|
134
|
+
if (event.pointerType === 'touch') {
|
|
135
|
+
this.touchPointers.set(event.pointerId, new Vector2(event.clientX, event.clientY))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (event.currentTarget instanceof Element) {
|
|
139
|
+
event.currentTarget.setPointerCapture?.(event.pointerId)
|
|
140
|
+
}
|
|
141
|
+
switch (event.button) {
|
|
142
|
+
case 0:
|
|
143
|
+
this.keys.add('mouseleft')
|
|
144
|
+
break;
|
|
145
|
+
case 2:
|
|
146
|
+
this.keys.add('mouseright')
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @this {OrbitCameraControls}
|
|
153
|
+
* @param {PointerEvent} event
|
|
154
|
+
*/
|
|
155
|
+
function mouseUp(event) {
|
|
156
|
+
event.preventDefault()
|
|
157
|
+
if (event.pointerType === 'touch') {
|
|
158
|
+
this.touchPointers.delete(event.pointerId)
|
|
159
|
+
}
|
|
160
|
+
if (event.currentTarget instanceof Element) {
|
|
161
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId)
|
|
162
|
+
}
|
|
163
|
+
switch (event.button) {
|
|
164
|
+
case 0:
|
|
165
|
+
this.keys.delete('mouseleft')
|
|
166
|
+
break;
|
|
167
|
+
case 2:
|
|
168
|
+
this.keys.delete('mouseright')
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @this {OrbitCameraControls}
|
|
175
|
+
*/
|
|
176
|
+
function cancelInput() {
|
|
177
|
+
this.keys.clear()
|
|
178
|
+
this.mouseDelta.set(0, 0)
|
|
179
|
+
this.touchPointers.clear()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @this {OrbitCameraControls}
|
|
184
|
+
* @param {PointerEvent} event
|
|
185
|
+
*/
|
|
186
|
+
function mousemove(event) {
|
|
187
|
+
if (event.pointerType === 'touch') {
|
|
188
|
+
const pointer = this.touchPointers.get(event.pointerId)
|
|
189
|
+
if (!pointer) return
|
|
190
|
+
event.preventDefault()
|
|
191
|
+
|
|
192
|
+
const prevX = pointer.x
|
|
193
|
+
const prevY = pointer.y
|
|
194
|
+
pointer.set(event.clientX, event.clientY)
|
|
195
|
+
|
|
196
|
+
if (this.touchPointers.size === 1) {
|
|
197
|
+
this.azimuth += -(event.clientX - prevX) * this.sensitivity
|
|
198
|
+
this.elevation += (event.clientY - prevY) * this.sensitivity
|
|
199
|
+
this.elevation = clamp(this.elevation, this.minElevation, this.maxElevation)
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (this.touchPointers.size >= 2) {
|
|
204
|
+
const entries = /**@type {[[number, Vector2], [number, Vector2]]}*/([...this.touchPointers.entries()])
|
|
205
|
+
const [id1, p1] = entries[0]
|
|
206
|
+
const [id2, p2] = entries[1]
|
|
207
|
+
|
|
208
|
+
const prevP1X = id1 === event.pointerId ? prevX : p1.x
|
|
209
|
+
const prevP1Y = id1 === event.pointerId ? prevY : p1.y
|
|
210
|
+
const prevP2X = id2 === event.pointerId ? prevX : p2.x
|
|
211
|
+
const prevP2Y = id2 === event.pointerId ? prevY : p2.y
|
|
212
|
+
|
|
213
|
+
const prevCenterX = (prevP1X + prevP2X) * 0.5
|
|
214
|
+
const prevCenterY = (prevP1Y + prevP2Y) * 0.5
|
|
215
|
+
const currCenterX = (p1.x + p2.x) * 0.5
|
|
216
|
+
const currCenterY = (p1.y + p2.y) * 0.5
|
|
217
|
+
|
|
218
|
+
applyPanFromScreenDelta(this, currCenterX - prevCenterX, currCenterY - prevCenterY)
|
|
219
|
+
|
|
220
|
+
const prevDistance = Math.hypot(prevP1X - prevP2X, prevP1Y - prevP2Y)
|
|
221
|
+
const currDistance = Math.hypot(p1.x - p2.x, p1.y - p2.y)
|
|
222
|
+
if (prevDistance > 0 && currDistance > 0) {
|
|
223
|
+
this.distance *= prevDistance / currDistance
|
|
224
|
+
this.distance = clamp(this.distance, this.minDistance, this.maxDistance)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.mouseDelta.copy(this.mousePosition)
|
|
231
|
+
this.mousePosition.set(event.clientX, event.clientY)
|
|
232
|
+
this.mouseDelta.subtract(this.mousePosition).reverse()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @this {OrbitCameraControls}
|
|
237
|
+
* @param {WheelEvent} event
|
|
238
|
+
*/
|
|
239
|
+
function mouseWheel(event) {
|
|
240
|
+
event.preventDefault()
|
|
241
|
+
this.distance *= Math.exp(event.deltaY * this.zoomSensitivity)
|
|
242
|
+
this.distance = clamp(this.distance, this.minDistance, this.maxDistance)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @param {OrbitCameraControls} controls
|
|
247
|
+
* @param {number} deltaX
|
|
248
|
+
* @param {number} deltaY
|
|
249
|
+
*/
|
|
250
|
+
function applyPanFromScreenDelta(controls, deltaX, deltaY) {
|
|
251
|
+
const input = Vector2.set(
|
|
252
|
+
-controls.moveSensitivity * deltaX,
|
|
253
|
+
-controls.moveSensitivity * deltaY
|
|
254
|
+
)
|
|
255
|
+
Vector2.rotate(input, -controls.azimuth, input)
|
|
256
|
+
controls.offset.x += input.x
|
|
257
|
+
controls.offset.z += input.y
|
|
258
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @enum {number}
|
|
3
|
+
*/
|
|
4
|
+
export const PrimitiveTopology = /** @type {const} */({
|
|
5
|
+
Points: 0x0000,
|
|
6
|
+
Lines: 0x0001,
|
|
7
|
+
LineLoop: 0x0002,
|
|
8
|
+
LineStrip: 0x0003,
|
|
9
|
+
Triangles: 0x0004,
|
|
10
|
+
TriangleStrip: 0x0005,
|
|
11
|
+
TriangleFan: 0x0006
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @enum {number}
|
|
16
|
+
*/
|
|
17
|
+
export const VertexFormat = /**@type {const}*/({
|
|
18
|
+
// 8-bit unsigned ints
|
|
19
|
+
Uint8: 0,
|
|
20
|
+
Uint8x2: 1,
|
|
21
|
+
Uint8x3: 2,
|
|
22
|
+
Uint8x4: 3,
|
|
23
|
+
|
|
24
|
+
Unorm8: 4,
|
|
25
|
+
Unorm8x2: 5,
|
|
26
|
+
Unorm8x3: 6,
|
|
27
|
+
Unorm8x4: 7,
|
|
28
|
+
|
|
29
|
+
// 8-bit signed ints
|
|
30
|
+
Sint8: 12,
|
|
31
|
+
Sint8x2: 13,
|
|
32
|
+
Sint8x3: 14,
|
|
33
|
+
Sint8x4: 15,
|
|
34
|
+
|
|
35
|
+
Snorm8: 8,
|
|
36
|
+
Snorm8x2: 9,
|
|
37
|
+
Snorm8x3: 10,
|
|
38
|
+
Snorm8x4: 11,
|
|
39
|
+
|
|
40
|
+
// 16-bit Unsigned int
|
|
41
|
+
Uint16: 16,
|
|
42
|
+
Uint16x2: 17,
|
|
43
|
+
Uint16x3: 18,
|
|
44
|
+
Uint16x4: 19,
|
|
45
|
+
|
|
46
|
+
Unorm16: 20,
|
|
47
|
+
Unorm16x2: 21,
|
|
48
|
+
Unorm16x3: 22,
|
|
49
|
+
Unorm16x4: 23,
|
|
50
|
+
|
|
51
|
+
// 16-bit signed int
|
|
52
|
+
Sint16: 28,
|
|
53
|
+
Sint16x2: 29,
|
|
54
|
+
Sint16x3: 30,
|
|
55
|
+
Sint16x4: 31,
|
|
56
|
+
|
|
57
|
+
Snorm16: 24,
|
|
58
|
+
Snorm16x2: 25,
|
|
59
|
+
Snorm16x3: 26,
|
|
60
|
+
Snorm16x4: 27,
|
|
61
|
+
|
|
62
|
+
// 32-bit unsigned int
|
|
63
|
+
Uint32: 32,
|
|
64
|
+
Uint32x2: 33,
|
|
65
|
+
Uint32x3: 34,
|
|
66
|
+
Uint32x4: 35,
|
|
67
|
+
|
|
68
|
+
// 32-bit signed ints
|
|
69
|
+
Sint32: 36,
|
|
70
|
+
Sint32x2: 37,
|
|
71
|
+
Sint32x3: 38,
|
|
72
|
+
Sint32x4: 39,
|
|
73
|
+
|
|
74
|
+
// 32-bit floating point
|
|
75
|
+
Float32: 40,
|
|
76
|
+
Float32x2: 41,
|
|
77
|
+
Float32x3: 42,
|
|
78
|
+
Float32x4: 43,
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @param {VertexFormat} vertexFormat
|
|
83
|
+
*/
|
|
84
|
+
export function getVertexFormatComponentNumber(vertexFormat) {
|
|
85
|
+
switch (vertexFormat) {
|
|
86
|
+
case VertexFormat.Uint8:
|
|
87
|
+
case VertexFormat.Unorm8:
|
|
88
|
+
case VertexFormat.Snorm8:
|
|
89
|
+
case VertexFormat.Sint8:
|
|
90
|
+
case VertexFormat.Uint16:
|
|
91
|
+
case VertexFormat.Unorm16:
|
|
92
|
+
case VertexFormat.Snorm16:
|
|
93
|
+
case VertexFormat.Sint16:
|
|
94
|
+
case VertexFormat.Uint32:
|
|
95
|
+
case VertexFormat.Sint32:
|
|
96
|
+
case VertexFormat.Float32:
|
|
97
|
+
return 1;
|
|
98
|
+
|
|
99
|
+
case VertexFormat.Uint8x2:
|
|
100
|
+
case VertexFormat.Unorm8x2:
|
|
101
|
+
case VertexFormat.Snorm8x2:
|
|
102
|
+
case VertexFormat.Sint8x2:
|
|
103
|
+
case VertexFormat.Uint16x2:
|
|
104
|
+
case VertexFormat.Unorm16x2:
|
|
105
|
+
case VertexFormat.Snorm16x2:
|
|
106
|
+
case VertexFormat.Sint16x2:
|
|
107
|
+
case VertexFormat.Uint32x2:
|
|
108
|
+
case VertexFormat.Sint32x2:
|
|
109
|
+
case VertexFormat.Float32x2:
|
|
110
|
+
return 2;
|
|
111
|
+
|
|
112
|
+
case VertexFormat.Uint8x3:
|
|
113
|
+
case VertexFormat.Unorm8x3:
|
|
114
|
+
case VertexFormat.Snorm8x3:
|
|
115
|
+
case VertexFormat.Sint8x3:
|
|
116
|
+
case VertexFormat.Uint16x3:
|
|
117
|
+
case VertexFormat.Unorm16x3:
|
|
118
|
+
case VertexFormat.Snorm16x3:
|
|
119
|
+
case VertexFormat.Sint16x3:
|
|
120
|
+
case VertexFormat.Uint32x3:
|
|
121
|
+
case VertexFormat.Sint32x3:
|
|
122
|
+
case VertexFormat.Float32x3:
|
|
123
|
+
return 3;
|
|
124
|
+
|
|
125
|
+
case VertexFormat.Uint8x4:
|
|
126
|
+
case VertexFormat.Unorm8x4:
|
|
127
|
+
case VertexFormat.Snorm8x4:
|
|
128
|
+
case VertexFormat.Sint8x4:
|
|
129
|
+
case VertexFormat.Uint16x4:
|
|
130
|
+
case VertexFormat.Unorm16x4:
|
|
131
|
+
case VertexFormat.Snorm16x4:
|
|
132
|
+
case VertexFormat.Sint16x4:
|
|
133
|
+
case VertexFormat.Uint32x4:
|
|
134
|
+
case VertexFormat.Sint32x4:
|
|
135
|
+
case VertexFormat.Float32x4:
|
|
136
|
+
return 4;
|
|
137
|
+
default:
|
|
138
|
+
throw new Error('Unsupported vertex format');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {VertexFormat} vertexFormat
|
|
144
|
+
*/
|
|
145
|
+
export function getVertexFormatComponentSize(vertexFormat) {
|
|
146
|
+
switch (vertexFormat) {
|
|
147
|
+
case VertexFormat.Uint8:
|
|
148
|
+
case VertexFormat.Unorm8:
|
|
149
|
+
case VertexFormat.Snorm8:
|
|
150
|
+
case VertexFormat.Sint8:
|
|
151
|
+
case VertexFormat.Uint8x2:
|
|
152
|
+
case VertexFormat.Unorm8x2:
|
|
153
|
+
case VertexFormat.Snorm8x2:
|
|
154
|
+
case VertexFormat.Sint8x2:
|
|
155
|
+
case VertexFormat.Uint8x3:
|
|
156
|
+
case VertexFormat.Unorm8x3:
|
|
157
|
+
case VertexFormat.Snorm8x3:
|
|
158
|
+
case VertexFormat.Sint8x3:
|
|
159
|
+
case VertexFormat.Uint8x4:
|
|
160
|
+
case VertexFormat.Unorm8x4:
|
|
161
|
+
case VertexFormat.Snorm8x4:
|
|
162
|
+
case VertexFormat.Sint8x4:
|
|
163
|
+
return 1;
|
|
164
|
+
case VertexFormat.Uint16:
|
|
165
|
+
case VertexFormat.Unorm16:
|
|
166
|
+
case VertexFormat.Snorm16:
|
|
167
|
+
case VertexFormat.Sint16:
|
|
168
|
+
case VertexFormat.Uint16x2:
|
|
169
|
+
case VertexFormat.Unorm16x2:
|
|
170
|
+
case VertexFormat.Snorm16x2:
|
|
171
|
+
case VertexFormat.Sint16x2:
|
|
172
|
+
case VertexFormat.Uint16x3:
|
|
173
|
+
case VertexFormat.Unorm16x3:
|
|
174
|
+
case VertexFormat.Snorm16x3:
|
|
175
|
+
case VertexFormat.Sint16x3:
|
|
176
|
+
case VertexFormat.Uint16x4:
|
|
177
|
+
case VertexFormat.Unorm16x4:
|
|
178
|
+
case VertexFormat.Snorm16x4:
|
|
179
|
+
case VertexFormat.Sint16x4:
|
|
180
|
+
return 2;
|
|
181
|
+
case VertexFormat.Uint32:
|
|
182
|
+
case VertexFormat.Uint32x2:
|
|
183
|
+
case VertexFormat.Uint32x3:
|
|
184
|
+
case VertexFormat.Uint32x4:
|
|
185
|
+
case VertexFormat.Sint32:
|
|
186
|
+
case VertexFormat.Sint32x2:
|
|
187
|
+
case VertexFormat.Sint32x3:
|
|
188
|
+
case VertexFormat.Sint32x4:
|
|
189
|
+
case VertexFormat.Float32:
|
|
190
|
+
case VertexFormat.Float32x2:
|
|
191
|
+
case VertexFormat.Float32x3:
|
|
192
|
+
case VertexFormat.Float32x4:
|
|
193
|
+
return 4;
|
|
194
|
+
default:
|
|
195
|
+
throw new Error('Unsupported vertex format');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @enum {number}
|
|
3
|
+
* Uniform types (scalars, vectors, matrices, and samplers).
|
|
4
|
+
*/
|
|
5
|
+
export const UniformType = /** @type {const} */({
|
|
6
|
+
// Scalars
|
|
7
|
+
Float: 0x1406,
|
|
8
|
+
Int: 0x1404,
|
|
9
|
+
Uint: 0x1405,
|
|
10
|
+
Bool: 0x8B56,
|
|
11
|
+
|
|
12
|
+
// Float vectors
|
|
13
|
+
Vec2: 0x8B50,
|
|
14
|
+
Vec3: 0x8B51,
|
|
15
|
+
Vec4: 0x8B52,
|
|
16
|
+
|
|
17
|
+
// Int vectors
|
|
18
|
+
IVec2: 0x8B53,
|
|
19
|
+
IVec3: 0x8B54,
|
|
20
|
+
IVec4: 0x8B55,
|
|
21
|
+
|
|
22
|
+
// Unsigned int vectors
|
|
23
|
+
UVec2: 0x8DC6,
|
|
24
|
+
UVec3: 0x8DC7,
|
|
25
|
+
UVec4: 0x8DC8,
|
|
26
|
+
|
|
27
|
+
// Bool vectors
|
|
28
|
+
BVec2: 0x8B57,
|
|
29
|
+
BVec3: 0x8B58,
|
|
30
|
+
BVec4: 0x8B59,
|
|
31
|
+
|
|
32
|
+
// Matrices
|
|
33
|
+
Mat2: 0x8B5A,
|
|
34
|
+
Mat3: 0x8B5B,
|
|
35
|
+
Mat4: 0x8B5C,
|
|
36
|
+
Mat2x3: 0x8B65,
|
|
37
|
+
Mat2x4: 0x8B66,
|
|
38
|
+
Mat3x2: 0x8B67,
|
|
39
|
+
Mat3x4: 0x8B68,
|
|
40
|
+
Mat4x2: 0x8B69,
|
|
41
|
+
Mat4x3: 0x8B6A,
|
|
42
|
+
|
|
43
|
+
// Samplers
|
|
44
|
+
Sampler2D: 0x8B5E,
|
|
45
|
+
Sampler3D: 0x8B5F,
|
|
46
|
+
SamplerCube: 0x8B60,
|
|
47
|
+
Sampler2DShadow: 0x8B62,
|
|
48
|
+
Sampler2DArray: 0x8DC1,
|
|
49
|
+
Sampler2DArrayShadow: 0x8DC4,
|
|
50
|
+
SamplerCubeShadow: 0x8DC5,
|
|
51
|
+
|
|
52
|
+
// Integer samplers
|
|
53
|
+
ISampler2D: 0x8DCA,
|
|
54
|
+
ISampler3D: 0x8DCB,
|
|
55
|
+
ISamplerCube: 0x8DCC,
|
|
56
|
+
ISampler2DArray: 0x8DCF,
|
|
57
|
+
|
|
58
|
+
// Unsigned integer samplers
|
|
59
|
+
USampler2D: 0x8DD2,
|
|
60
|
+
USampler3D: 0x8DD3,
|
|
61
|
+
USamplerCube: 0x8DD4,
|
|
62
|
+
USampler2DArray: 0x8DD7
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @enum {number}
|
|
67
|
+
*/
|
|
68
|
+
export const GlDataType = /** @type {const} */({
|
|
69
|
+
Float: 0x1406,
|
|
70
|
+
UnsignedInt: 0x1405,
|
|
71
|
+
Int: 0x1404,
|
|
72
|
+
UnsignedShort: 0x1403,
|
|
73
|
+
Short: 0x1402,
|
|
74
|
+
UnsignedByte: 0x1401,
|
|
75
|
+
Byte: 0x1400
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @enum {number}
|
|
81
|
+
*/
|
|
82
|
+
export const BufferUsage = /** @type {const} */({
|
|
83
|
+
Static: 0x88E4,
|
|
84
|
+
Dynamic: 0x88E8,
|
|
85
|
+
Stream: 0x88E0
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @enum {number}
|
|
90
|
+
* Buffer binding targets
|
|
91
|
+
*/
|
|
92
|
+
export const BufferTarget = /** @type {const} */({
|
|
93
|
+
ArrayBuffer: 0x8892, // gl.ARRAY_BUFFER
|
|
94
|
+
ElementArrayBuffer: 0x8893, // gl.ELEMENT_ARRAY_BUFFER
|
|
95
|
+
CopyReadBuffer: 0x8F36, // gl.COPY_READ_BUFFER
|
|
96
|
+
CopyWriteBuffer: 0x8F37, // gl.COPY_WRITE_BUFFER
|
|
97
|
+
PixelPackBuffer: 0x88EB, // gl.PIXEL_PACK_BUFFER
|
|
98
|
+
PixelUnpackBuffer: 0x88EC, // gl.PIXEL_UNPACK_BUFFER
|
|
99
|
+
UniformBuffer: 0x8A11, // gl.UNIFORM_BUFFER
|
|
100
|
+
TransformFeedbackBuffer: 0x8C8E // gl.TRANSFORM_FEEDBACK_BUFFER
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @enum {number}
|
|
105
|
+
* Face culling modes
|
|
106
|
+
*/
|
|
107
|
+
export const CullFace = /** @type {const} */({
|
|
108
|
+
None: 0x0000, // Represents no culling
|
|
109
|
+
Front: 0x0404, // gl.FRONT
|
|
110
|
+
Back: 0x0405, // gl.BACK
|
|
111
|
+
FrontAndBack: 0x0408 // gl.FRONT_AND_BACK
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @enum {number}
|
|
116
|
+
* Blend function factors
|
|
117
|
+
*/
|
|
118
|
+
export const BlendMode = /** @type {const} */({
|
|
119
|
+
Zero: 0x0000, // gl.ZERO
|
|
120
|
+
One: 0x0001, // gl.ONE
|
|
121
|
+
SrcColor: 0x0300, // gl.SRC_COLOR
|
|
122
|
+
OneMinusSrcColor: 0x0301, // gl.ONE_MINUS_SRC_COLOR
|
|
123
|
+
SrcAlpha: 0x0302, // gl.SRC_ALPHA
|
|
124
|
+
OneMinusSrcAlpha: 0x0303, // gl.ONE_MINUS_SRC_ALPHA
|
|
125
|
+
DstAlpha: 0x0304, // gl.DST_ALPHA
|
|
126
|
+
OneMinusDstAlpha: 0x0305, // gl.ONE_MINUS_DST_ALPHA
|
|
127
|
+
DstColor: 0x0306, // gl.DST_COLOR
|
|
128
|
+
OneMinusDstColor: 0x0307, // gl.ONE_MINUS_DST_COLOR
|
|
129
|
+
SrcAlphaSaturate: 0x0308, // gl.SRC_ALPHA_SATURATE
|
|
130
|
+
ConstantColor: 0x8001, // gl.CONSTANT_COLOR
|
|
131
|
+
OneMinusConstantColor: 0x8002, // gl.ONE_MINUS_CONSTANT_COLOR
|
|
132
|
+
ConstantAlpha: 0x8003, // gl.CONSTANT_ALPHA
|
|
133
|
+
OneMinusConstantAlpha: 0x8004 // gl.ONE_MINUS_CONSTANT_ALPHA
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @enum {number}
|
|
138
|
+
* Blend equation modes
|
|
139
|
+
*/
|
|
140
|
+
export const BlendEquation = /** @type {const} */({
|
|
141
|
+
Add: 0x8006, // gl.FUNC_ADD
|
|
142
|
+
Subtract: 0x800A, // gl.FUNC_SUBTRACT
|
|
143
|
+
ReverseSubtract: 0x800B, // gl.FUNC_REVERSE_SUBTRACT
|
|
144
|
+
Min: 0x8007, // gl.MIN
|
|
145
|
+
Max: 0x8008 // gl.MAX
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @enum {number}
|
|
150
|
+
* Stencil and depth buffer operations.
|
|
151
|
+
*/
|
|
152
|
+
export const StencilOp = /** @type {const} */({
|
|
153
|
+
Keep: 0x1E00, // gl.KEEP
|
|
154
|
+
Zero: 0x0000, // gl.ZERO
|
|
155
|
+
Replace: 0x1E01, // gl.REPLACE
|
|
156
|
+
Incr: 0x1E02, // gl.INCR
|
|
157
|
+
IncrWrap: 0x8507, // gl.INCR_WRAP
|
|
158
|
+
Decr: 0x1E03, // gl.DECR
|
|
159
|
+
DecrWrap: 0x8508, // gl.DECR_WRAP
|
|
160
|
+
Invert: 0x150A // gl.INVERT
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @enum {number}
|
|
165
|
+
* Polygon winding directions for front-face determination.
|
|
166
|
+
*/
|
|
167
|
+
export const FrontFaceDirection = /** @type {const} */({
|
|
168
|
+
CW: 0x0900, // gl.CW
|
|
169
|
+
CCW: 0x0901 // gl.CCW
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* @enum {number}
|
|
174
|
+
* Primitive output modes for transform feedback
|
|
175
|
+
*/
|
|
176
|
+
export const TransformFeedbackPrimitiveTopology = /** @type {const} */({
|
|
177
|
+
Points: 0x0000, // gl.POINTS
|
|
178
|
+
Lines: 0x0001, // gl.LINES
|
|
179
|
+
Triangles: 0x0004 // gl.TRIANGLES
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @enum {number}
|
|
184
|
+
* Buffer storage modes for transform feedback varyings
|
|
185
|
+
*/
|
|
186
|
+
export const TransformFeedbackBufferMode = /** @type {const} */({
|
|
187
|
+
Interleaved: 0x8C8C, // gl.INTERLEAVED_ATTRIBS
|
|
188
|
+
Separate: 0x8C8D // gl.SEPARATE_ATTRIBS
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @enum {number}
|
|
193
|
+
* Internal formats for renderbuffers
|
|
194
|
+
*/
|
|
195
|
+
export const RenderbufferFormat = /** @type {const} */({
|
|
196
|
+
Rgba4: 0x8056, // gl.RGBA4
|
|
197
|
+
Rgb565: 0x8D62, // gl.RGB565
|
|
198
|
+
Rgb5A1: 0x8057, // gl.RGB5_A1
|
|
199
|
+
Depth16: 0x81A5, // gl.DEPTH_COMPONENT16
|
|
200
|
+
Stencil8: 0x8D48, // gl.STENCIL_INDEX8
|
|
201
|
+
Depth24: 0x81A6, // gl.DEPTH_COMPONENT24
|
|
202
|
+
Depth32f: 0x8CAC, // gl.DEPTH_COMPONENT32F
|
|
203
|
+
Depth24Stencil8: 0x88F0, // gl.DEPTH24_STENCIL8
|
|
204
|
+
Depth32fStencil8: 0x8CAD // gl.DEPTH32F_STENCIL8
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* @enum {number}
|
|
209
|
+
*/
|
|
210
|
+
export const BufferType = /**@type {const}*/({
|
|
211
|
+
Array:0x8892,
|
|
212
|
+
ElementArray:0x8893,
|
|
213
|
+
CopyRead:0x8F36,
|
|
214
|
+
CopyWrite:0x8F37,
|
|
215
|
+
Uniform:0x8A11,
|
|
216
|
+
PixelPack:0x88EB,
|
|
217
|
+
PixelUnpack:0x88EC
|
|
218
|
+
})
|