@damienmortini/three 0.1.187 → 0.1.188
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/LICENSE +4 -4
- package/copyExamples.js +17 -17
- package/ecs/THREEView.js +31 -31
- package/gpgpu/THREEGPGPUSystem.js +175 -175
- package/loader/THREELoader.js +117 -117
- package/loader/meshoptimizerdecoder/THREE.EXT_meshopt_compression.js +41 -41
- package/loader/meshoptimizerdecoder/meshopt_decoder.js +129 -129
- package/material/THREEBaseMaterial.js +75 -75
- package/material/THREEPBRMaterial.js +107 -107
- package/material/THREEShaderMaterial.js +97 -97
- package/object/THREELine.js +113 -113
- package/object/THREEMotionVectorObject.js +284 -284
- package/object/THREERibbon.js +49 -49
- package/object/THREESky.js +281 -281
- package/object/THREESprite.js +96 -96
- package/object/THREESpriteAnimation.js +103 -103
- package/object/THREEText.js +241 -241
- package/package.json +6 -5
- package/renderer/THREERenderer.js +123 -123
- package/renderer/THREEStereoRenderer.js +60 -60
- package/renderer/WebGLRenderTarget2D.js +63 -63
- package/shader/THREEBaseShader.js +33 -33
- package/types/index.d.ts +1 -1
- package/types/renderer/WebGLRenderTarget2D.d.ts +42 -42
package/LICENSE
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
Copyright 2019 Damien Mortini
|
|
2
|
-
|
|
3
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
4
|
-
|
|
1
|
+
Copyright 2019 Damien Mortini
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
4
|
+
|
|
5
5
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/copyExamples.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const fs = require('fs-extra')
|
|
2
|
-
|
|
3
|
-
const files = new Map([
|
|
4
|
-
[require.resolve('three/examples/jsm/loaders/BasisTextureLoader.js'), './examples/loaders/BasisTextureLoader.js'],
|
|
5
|
-
[require.resolve('three/examples/jsm/loaders/GLTFLoader.js'), './examples/loaders/GLTFLoader.js'],
|
|
6
|
-
[require.resolve('three/examples/jsm/loaders/DRACOLoader.js'), './examples/loaders/DRACOLoader.js'],
|
|
7
|
-
[require.resolve('three/examples/jsm/loaders/KTX2Loader.js'), './examples/loaders/KTX2Loader.js'],
|
|
8
|
-
[require.resolve('three/examples/jsm/utils/WorkerPool.js'), './examples/utils/WorkerPool.js'],
|
|
9
|
-
[require.resolve('three/examples/jsm/objects/Lensflare.js'), './examples/objects/Lensflare.js'],
|
|
10
|
-
[require.resolve('three/examples/jsm/utils/BufferGeometryUtils.js'), './examples/utils/BufferGeometryUtils.js'],
|
|
11
|
-
])
|
|
12
|
-
for (const [source, destination] of files) {
|
|
13
|
-
fs.copySync(source, destination)
|
|
14
|
-
const data = fs.readFileSync(destination, 'utf-8')
|
|
15
|
-
const newValue = data.replace('from \'three\'', 'from \'../../../../three/src/Three.js\'')
|
|
16
|
-
fs.writeFileSync(destination, newValue, 'utf-8')
|
|
17
|
-
}
|
|
1
|
+
const fs = require('fs-extra')
|
|
2
|
+
|
|
3
|
+
const files = new Map([
|
|
4
|
+
[require.resolve('three/examples/jsm/loaders/BasisTextureLoader.js'), './examples/loaders/BasisTextureLoader.js'],
|
|
5
|
+
[require.resolve('three/examples/jsm/loaders/GLTFLoader.js'), './examples/loaders/GLTFLoader.js'],
|
|
6
|
+
[require.resolve('three/examples/jsm/loaders/DRACOLoader.js'), './examples/loaders/DRACOLoader.js'],
|
|
7
|
+
[require.resolve('three/examples/jsm/loaders/KTX2Loader.js'), './examples/loaders/KTX2Loader.js'],
|
|
8
|
+
[require.resolve('three/examples/jsm/utils/WorkerPool.js'), './examples/utils/WorkerPool.js'],
|
|
9
|
+
[require.resolve('three/examples/jsm/objects/Lensflare.js'), './examples/objects/Lensflare.js'],
|
|
10
|
+
[require.resolve('three/examples/jsm/utils/BufferGeometryUtils.js'), './examples/utils/BufferGeometryUtils.js'],
|
|
11
|
+
])
|
|
12
|
+
for (const [source, destination] of files) {
|
|
13
|
+
fs.copySync(source, destination)
|
|
14
|
+
const data = fs.readFileSync(destination, 'utf-8')
|
|
15
|
+
const newValue = data.replace('from \'three\'', 'from \'../../../../three/src/Three.js\'')
|
|
16
|
+
fs.writeFileSync(destination, newValue, 'utf-8')
|
|
17
|
+
}
|
package/ecs/THREEView.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import View from '../ecs/components/View.js'
|
|
2
|
-
|
|
3
|
-
export default class THREEView extends View {
|
|
4
|
-
constructor(entity, {
|
|
5
|
-
view = new THREE.Object3D(),
|
|
6
|
-
visible,
|
|
7
|
-
visibilityExecutor,
|
|
8
|
-
} = {}) {
|
|
9
|
-
super(entity, view, { visible, visibilityExecutor })
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get position() {
|
|
13
|
-
return this._view.position
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get rotation() {
|
|
17
|
-
return this._view.rotation
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get quaternion() {
|
|
21
|
-
return this._view.quaternion
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
get scale() {
|
|
25
|
-
return this._view.scale
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
get object3D() {
|
|
29
|
-
return this._view
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import View from '../ecs/components/View.js'
|
|
2
|
+
|
|
3
|
+
export default class THREEView extends View {
|
|
4
|
+
constructor(entity, {
|
|
5
|
+
view = new THREE.Object3D(),
|
|
6
|
+
visible,
|
|
7
|
+
visibilityExecutor,
|
|
8
|
+
} = {}) {
|
|
9
|
+
super(entity, view, { visible, visibilityExecutor })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
get position() {
|
|
13
|
+
return this._view.position
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get rotation() {
|
|
17
|
+
return this._view.rotation
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get quaternion() {
|
|
21
|
+
return this._view.quaternion
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get scale() {
|
|
25
|
+
return this._view.scale
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get object3D() {
|
|
29
|
+
return this._view
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
import { Mesh, OrthographicCamera, PlaneBufferGeometry, DataTexture, RGBAFormat, FloatType, WebGLRenderer, WebGLRenderTarget, Scene, NearestFilter, RGBFormat, HalfFloatType, MathUtils } from '../../../three/src/Three.js'
|
|
2
|
-
|
|
3
|
-
import THREEShaderMaterial from '../material/THREEShaderMaterial.js'
|
|
4
|
-
import DatatextureShader from '@damienmortini/core/shader/DataTextureShader.js'
|
|
5
|
-
import Float16 from '@damienmortini/core/math/Float16.js'
|
|
6
|
-
|
|
7
|
-
let DEBUG_RENDERER
|
|
8
|
-
|
|
9
|
-
export default class THREEGPGPUSystem {
|
|
10
|
-
constructor({
|
|
11
|
-
data,
|
|
12
|
-
renderer,
|
|
13
|
-
uniforms = {},
|
|
14
|
-
stride = 1,
|
|
15
|
-
fragmentChunks = [],
|
|
16
|
-
format = RGBAFormat,
|
|
17
|
-
debug = false,
|
|
18
|
-
}) {
|
|
19
|
-
this._renderer = renderer
|
|
20
|
-
this._stride = stride
|
|
21
|
-
|
|
22
|
-
const channels = format === RGBFormat ? 3 : 4
|
|
23
|
-
const dataSize = data.length / channels / stride
|
|
24
|
-
const width = MathUtils.ceilPowerOfTwo(Math.sqrt(dataSize))
|
|
25
|
-
this._dataTextureWidth = width * stride
|
|
26
|
-
this._dataTextureHeight = MathUtils.ceilPowerOfTwo(dataSize / width)
|
|
27
|
-
|
|
28
|
-
this.debug = debug
|
|
29
|
-
|
|
30
|
-
const finalData = new Float32Array(this._dataTextureWidth * this._dataTextureHeight * channels)
|
|
31
|
-
finalData.set(data)
|
|
32
|
-
let dataTexture
|
|
33
|
-
// if (renderer.capabilities.isWebGL2) {
|
|
34
|
-
dataTexture = new DataTexture(finalData, this._dataTextureWidth, this._dataTextureHeight, format, FloatType)
|
|
35
|
-
// } else {
|
|
36
|
-
// dataTexture = new DataTexture(Float16.fromFloat32Array(finalData), this._dataTextureWidth, this._dataTextureHeight, format, HalfFloatType);
|
|
37
|
-
// }
|
|
38
|
-
dataTexture.needsUpdate = true
|
|
39
|
-
|
|
40
|
-
this.camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)
|
|
41
|
-
this.scene = new Scene()
|
|
42
|
-
|
|
43
|
-
this._webglRenderTargetIn = new WebGLRenderTarget(this._dataTextureWidth, this._dataTextureHeight, {
|
|
44
|
-
minFilter: NearestFilter,
|
|
45
|
-
magFilter: NearestFilter,
|
|
46
|
-
format,
|
|
47
|
-
stencilBuffer: false,
|
|
48
|
-
depthBuffer: false,
|
|
49
|
-
type: renderer.capabilities.isWebGL2 ? FloatType : HalfFloatType, // Half float for iOS
|
|
50
|
-
})
|
|
51
|
-
this._webglRenderTargetIn.texture.generateMipmaps = false
|
|
52
|
-
this._webglRenderTargetOut = this._webglRenderTargetIn.clone()
|
|
53
|
-
|
|
54
|
-
this._quad = new Mesh(new PlaneBufferGeometry(2, 2), new THREEShaderMaterial({
|
|
55
|
-
uniforms: {
|
|
56
|
-
dataTexture,
|
|
57
|
-
...uniforms,
|
|
58
|
-
},
|
|
59
|
-
fragment: `
|
|
60
|
-
void main() {
|
|
61
|
-
gl_FragColor = vec4(0.);
|
|
62
|
-
}
|
|
63
|
-
`,
|
|
64
|
-
vertexChunks: [
|
|
65
|
-
['start',
|
|
66
|
-
'out vec2 vUV;',
|
|
67
|
-
],
|
|
68
|
-
['main',
|
|
69
|
-
'vUV = uv;',
|
|
70
|
-
],
|
|
71
|
-
],
|
|
72
|
-
fragmentChunks: [
|
|
73
|
-
...fragmentChunks,
|
|
74
|
-
['start', `
|
|
75
|
-
#define DATA_TEXTURE_WIDTH ${this.dataTextureWidth.toFixed(1)}
|
|
76
|
-
#define DATA_TEXTURE_HEIGHT ${this.dataTextureHeight.toFixed(1)}
|
|
77
|
-
|
|
78
|
-
uniform highp sampler2D dataTexture;
|
|
79
|
-
|
|
80
|
-
in vec2 vUV;
|
|
81
|
-
|
|
82
|
-
${DatatextureShader.getTextureDataChunkFromUV()}
|
|
83
|
-
|
|
84
|
-
vec4 getDataChunk(int chunkIndex) {
|
|
85
|
-
return getTextureDataChunkFromUV(dataTexture, vUV, chunkIndex, ${stride}, vec2(DATA_TEXTURE_WIDTH, DATA_TEXTURE_HEIGHT));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
int getDataIndex() {
|
|
89
|
-
vec2 dataPosition = floor(vUV * vec2(DATA_TEXTURE_WIDTH / float(${stride}), DATA_TEXTURE_HEIGHT));
|
|
90
|
-
return int(dataPosition.x + dataPosition.y * DATA_TEXTURE_WIDTH / float(${stride}));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
int getChunkIndex() {
|
|
94
|
-
return int(mod(vUV * DATA_TEXTURE_WIDTH, float(${stride})));
|
|
95
|
-
}
|
|
96
|
-
`],
|
|
97
|
-
],
|
|
98
|
-
}))
|
|
99
|
-
this.scene.add(this._quad)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get onBeforeRender() {
|
|
103
|
-
return this._quad.onBeforeRender
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
set onBeforeRender(value) {
|
|
107
|
-
this._quad.onBeforeRender = value
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
get material() {
|
|
111
|
-
return this._quad.material
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
get dataTextureWidth() {
|
|
115
|
-
return this._dataTextureWidth
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
get dataTextureHeight() {
|
|
119
|
-
return this._dataTextureHeight
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
get dataTextureSize() {
|
|
123
|
-
return [this._dataTextureWidth, this._dataTextureHeight]
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get dataTexture() {
|
|
127
|
-
return this._quad.material.dataTexture
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
get stride() {
|
|
131
|
-
return this._stride
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
get debug() {
|
|
135
|
-
return this._debug
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
set debug(value) {
|
|
139
|
-
this._debug = value
|
|
140
|
-
if (this._debug && !DEBUG_RENDERER) {
|
|
141
|
-
DEBUG_RENDERER = new WebGLRenderer()
|
|
142
|
-
document.body.appendChild(DEBUG_RENDERER.domElement)
|
|
143
|
-
DEBUG_RENDERER.setSize(this._dataTextureWidth, this._dataTextureHeight, false)
|
|
144
|
-
DEBUG_RENDERER.domElement.style.position = 'absolute'
|
|
145
|
-
DEBUG_RENDERER.domElement.style.bottom = '0'
|
|
146
|
-
DEBUG_RENDERER.domElement.style.left = '0'
|
|
147
|
-
DEBUG_RENDERER.domElement.style.width = '100%'
|
|
148
|
-
DEBUG_RENDERER.domElement.style.height = '25%'
|
|
149
|
-
DEBUG_RENDERER.domElement.style.imageRendering = 'pixelated'
|
|
150
|
-
}
|
|
151
|
-
if (DEBUG_RENDERER) {
|
|
152
|
-
DEBUG_RENDERER.domElement.hidden = !this._debug
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
update() {
|
|
157
|
-
const savedRendertarget = this._renderer.getRenderTarget()
|
|
158
|
-
|
|
159
|
-
this._renderer.setRenderTarget(this._webglRenderTargetOut)
|
|
160
|
-
this._renderer.render(this.scene, this.camera)
|
|
161
|
-
|
|
162
|
-
if (this.debug) {
|
|
163
|
-
DEBUG_RENDERER.setRenderTarget(this._webglRenderTargetOut)
|
|
164
|
-
DEBUG_RENDERER.render(this.scene, this.camera)
|
|
165
|
-
DEBUG_RENDERER.setRenderTarget(null)
|
|
166
|
-
DEBUG_RENDERER.render(this.scene, this.camera)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
[this._webglRenderTargetIn, this._webglRenderTargetOut] = [this._webglRenderTargetOut, this._webglRenderTargetIn]
|
|
170
|
-
|
|
171
|
-
this._quad.material.dataTexture = this._webglRenderTargetIn.texture
|
|
172
|
-
|
|
173
|
-
this._renderer.setRenderTarget(savedRendertarget)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
1
|
+
import { Mesh, OrthographicCamera, PlaneBufferGeometry, DataTexture, RGBAFormat, FloatType, WebGLRenderer, WebGLRenderTarget, Scene, NearestFilter, RGBFormat, HalfFloatType, MathUtils } from '../../../three/src/Three.js'
|
|
2
|
+
|
|
3
|
+
import THREEShaderMaterial from '../material/THREEShaderMaterial.js'
|
|
4
|
+
import DatatextureShader from '@damienmortini/core/shader/DataTextureShader.js'
|
|
5
|
+
import Float16 from '@damienmortini/core/math/Float16.js'
|
|
6
|
+
|
|
7
|
+
let DEBUG_RENDERER
|
|
8
|
+
|
|
9
|
+
export default class THREEGPGPUSystem {
|
|
10
|
+
constructor({
|
|
11
|
+
data,
|
|
12
|
+
renderer,
|
|
13
|
+
uniforms = {},
|
|
14
|
+
stride = 1,
|
|
15
|
+
fragmentChunks = [],
|
|
16
|
+
format = RGBAFormat,
|
|
17
|
+
debug = false,
|
|
18
|
+
}) {
|
|
19
|
+
this._renderer = renderer
|
|
20
|
+
this._stride = stride
|
|
21
|
+
|
|
22
|
+
const channels = format === RGBFormat ? 3 : 4
|
|
23
|
+
const dataSize = data.length / channels / stride
|
|
24
|
+
const width = MathUtils.ceilPowerOfTwo(Math.sqrt(dataSize))
|
|
25
|
+
this._dataTextureWidth = width * stride
|
|
26
|
+
this._dataTextureHeight = MathUtils.ceilPowerOfTwo(dataSize / width)
|
|
27
|
+
|
|
28
|
+
this.debug = debug
|
|
29
|
+
|
|
30
|
+
const finalData = new Float32Array(this._dataTextureWidth * this._dataTextureHeight * channels)
|
|
31
|
+
finalData.set(data)
|
|
32
|
+
let dataTexture
|
|
33
|
+
// if (renderer.capabilities.isWebGL2) {
|
|
34
|
+
dataTexture = new DataTexture(finalData, this._dataTextureWidth, this._dataTextureHeight, format, FloatType)
|
|
35
|
+
// } else {
|
|
36
|
+
// dataTexture = new DataTexture(Float16.fromFloat32Array(finalData), this._dataTextureWidth, this._dataTextureHeight, format, HalfFloatType);
|
|
37
|
+
// }
|
|
38
|
+
dataTexture.needsUpdate = true
|
|
39
|
+
|
|
40
|
+
this.camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)
|
|
41
|
+
this.scene = new Scene()
|
|
42
|
+
|
|
43
|
+
this._webglRenderTargetIn = new WebGLRenderTarget(this._dataTextureWidth, this._dataTextureHeight, {
|
|
44
|
+
minFilter: NearestFilter,
|
|
45
|
+
magFilter: NearestFilter,
|
|
46
|
+
format,
|
|
47
|
+
stencilBuffer: false,
|
|
48
|
+
depthBuffer: false,
|
|
49
|
+
type: renderer.capabilities.isWebGL2 ? FloatType : HalfFloatType, // Half float for iOS
|
|
50
|
+
})
|
|
51
|
+
this._webglRenderTargetIn.texture.generateMipmaps = false
|
|
52
|
+
this._webglRenderTargetOut = this._webglRenderTargetIn.clone()
|
|
53
|
+
|
|
54
|
+
this._quad = new Mesh(new PlaneBufferGeometry(2, 2), new THREEShaderMaterial({
|
|
55
|
+
uniforms: {
|
|
56
|
+
dataTexture,
|
|
57
|
+
...uniforms,
|
|
58
|
+
},
|
|
59
|
+
fragment: `
|
|
60
|
+
void main() {
|
|
61
|
+
gl_FragColor = vec4(0.);
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
vertexChunks: [
|
|
65
|
+
['start',
|
|
66
|
+
'out vec2 vUV;',
|
|
67
|
+
],
|
|
68
|
+
['main',
|
|
69
|
+
'vUV = uv;',
|
|
70
|
+
],
|
|
71
|
+
],
|
|
72
|
+
fragmentChunks: [
|
|
73
|
+
...fragmentChunks,
|
|
74
|
+
['start', `
|
|
75
|
+
#define DATA_TEXTURE_WIDTH ${this.dataTextureWidth.toFixed(1)}
|
|
76
|
+
#define DATA_TEXTURE_HEIGHT ${this.dataTextureHeight.toFixed(1)}
|
|
77
|
+
|
|
78
|
+
uniform highp sampler2D dataTexture;
|
|
79
|
+
|
|
80
|
+
in vec2 vUV;
|
|
81
|
+
|
|
82
|
+
${DatatextureShader.getTextureDataChunkFromUV()}
|
|
83
|
+
|
|
84
|
+
vec4 getDataChunk(int chunkIndex) {
|
|
85
|
+
return getTextureDataChunkFromUV(dataTexture, vUV, chunkIndex, ${stride}, vec2(DATA_TEXTURE_WIDTH, DATA_TEXTURE_HEIGHT));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
int getDataIndex() {
|
|
89
|
+
vec2 dataPosition = floor(vUV * vec2(DATA_TEXTURE_WIDTH / float(${stride}), DATA_TEXTURE_HEIGHT));
|
|
90
|
+
return int(dataPosition.x + dataPosition.y * DATA_TEXTURE_WIDTH / float(${stride}));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
int getChunkIndex() {
|
|
94
|
+
return int(mod(vUV * DATA_TEXTURE_WIDTH, float(${stride})));
|
|
95
|
+
}
|
|
96
|
+
`],
|
|
97
|
+
],
|
|
98
|
+
}))
|
|
99
|
+
this.scene.add(this._quad)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get onBeforeRender() {
|
|
103
|
+
return this._quad.onBeforeRender
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
set onBeforeRender(value) {
|
|
107
|
+
this._quad.onBeforeRender = value
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
get material() {
|
|
111
|
+
return this._quad.material
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get dataTextureWidth() {
|
|
115
|
+
return this._dataTextureWidth
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get dataTextureHeight() {
|
|
119
|
+
return this._dataTextureHeight
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get dataTextureSize() {
|
|
123
|
+
return [this._dataTextureWidth, this._dataTextureHeight]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get dataTexture() {
|
|
127
|
+
return this._quad.material.dataTexture
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get stride() {
|
|
131
|
+
return this._stride
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get debug() {
|
|
135
|
+
return this._debug
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
set debug(value) {
|
|
139
|
+
this._debug = value
|
|
140
|
+
if (this._debug && !DEBUG_RENDERER) {
|
|
141
|
+
DEBUG_RENDERER = new WebGLRenderer()
|
|
142
|
+
document.body.appendChild(DEBUG_RENDERER.domElement)
|
|
143
|
+
DEBUG_RENDERER.setSize(this._dataTextureWidth, this._dataTextureHeight, false)
|
|
144
|
+
DEBUG_RENDERER.domElement.style.position = 'absolute'
|
|
145
|
+
DEBUG_RENDERER.domElement.style.bottom = '0'
|
|
146
|
+
DEBUG_RENDERER.domElement.style.left = '0'
|
|
147
|
+
DEBUG_RENDERER.domElement.style.width = '100%'
|
|
148
|
+
DEBUG_RENDERER.domElement.style.height = '25%'
|
|
149
|
+
DEBUG_RENDERER.domElement.style.imageRendering = 'pixelated'
|
|
150
|
+
}
|
|
151
|
+
if (DEBUG_RENDERER) {
|
|
152
|
+
DEBUG_RENDERER.domElement.hidden = !this._debug
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
update() {
|
|
157
|
+
const savedRendertarget = this._renderer.getRenderTarget()
|
|
158
|
+
|
|
159
|
+
this._renderer.setRenderTarget(this._webglRenderTargetOut)
|
|
160
|
+
this._renderer.render(this.scene, this.camera)
|
|
161
|
+
|
|
162
|
+
if (this.debug) {
|
|
163
|
+
DEBUG_RENDERER.setRenderTarget(this._webglRenderTargetOut)
|
|
164
|
+
DEBUG_RENDERER.render(this.scene, this.camera)
|
|
165
|
+
DEBUG_RENDERER.setRenderTarget(null)
|
|
166
|
+
DEBUG_RENDERER.render(this.scene, this.camera)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[this._webglRenderTargetIn, this._webglRenderTargetOut] = [this._webglRenderTargetOut, this._webglRenderTargetIn]
|
|
170
|
+
|
|
171
|
+
this._quad.material.dataTexture = this._webglRenderTargetIn.texture
|
|
172
|
+
|
|
173
|
+
this._renderer.setRenderTarget(savedRendertarget)
|
|
174
|
+
}
|
|
175
|
+
}
|