@geastack/native-webgl-angle 0.1.17 → 0.1.18
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/geatsc-plugin-uniforms.mjs +135 -56
- package/geatsc-plugin.mjs +1 -1
- package/native/angle_webgl_host.mm +5 -2
- package/package.json +1 -1
- package/src/nativeWebGL.ts +6 -1
- package/src/nativeWebGLHost.ts +2 -2
|
@@ -349,42 +349,86 @@ export function isUniformNumberArray( value ) {
|
|
|
349
349
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
-
/**
|
|
353
|
-
|
|
352
|
+
/**
|
|
353
|
+
* One element of a uniform array whose first element is the given kind. Read
|
|
354
|
+
* through \`Array.isArray\` and \`instanceof\` on the element itself rather than
|
|
355
|
+
* through the value narrowed to that array type: the value is stored as the
|
|
356
|
+
* uniform union, and claiming one array arm for it is an array-to-array
|
|
357
|
+
* conversion with no runtime form.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Vector2} */
|
|
361
|
+
function vector2ArrayElement( value, index ) {
|
|
362
|
+
|
|
363
|
+
\tif ( Array.isArray( value ) ) {
|
|
364
|
+
|
|
365
|
+
\t\tconst element = value[ index ];
|
|
366
|
+
|
|
367
|
+
\t\tif ( element instanceof Vector2 ) return element;
|
|
368
|
+
|
|
369
|
+
\t}
|
|
354
370
|
|
|
355
|
-
\
|
|
371
|
+
\tthrow new Error( 'THREE.UniformsUtils: a uniform array mixes Vector2 with other values.' );
|
|
356
372
|
|
|
357
373
|
}
|
|
358
374
|
|
|
359
|
-
/** @param {NativeUniformValue} value @
|
|
360
|
-
function
|
|
375
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Vector3} */
|
|
376
|
+
function vector3ArrayElement( value, index ) {
|
|
377
|
+
|
|
378
|
+
\tif ( Array.isArray( value ) ) {
|
|
361
379
|
|
|
362
|
-
\
|
|
380
|
+
\t\tconst element = value[ index ];
|
|
381
|
+
|
|
382
|
+
\t\tif ( element instanceof Vector3 ) return element;
|
|
383
|
+
|
|
384
|
+
\t}
|
|
385
|
+
|
|
386
|
+
\tthrow new Error( 'THREE.UniformsUtils: a uniform array mixes Vector3 with other values.' );
|
|
363
387
|
|
|
364
388
|
}
|
|
365
389
|
|
|
366
|
-
/** @param {NativeUniformValue} value @
|
|
367
|
-
function
|
|
390
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Vector4} */
|
|
391
|
+
function vector4ArrayElement( value, index ) {
|
|
392
|
+
|
|
393
|
+
\tif ( Array.isArray( value ) ) {
|
|
368
394
|
|
|
369
|
-
\
|
|
395
|
+
\t\tconst element = value[ index ];
|
|
396
|
+
|
|
397
|
+
\t\tif ( element instanceof Vector4 ) return element;
|
|
398
|
+
|
|
399
|
+
\t}
|
|
400
|
+
|
|
401
|
+
\tthrow new Error( 'THREE.UniformsUtils: a uniform array mixes Vector4 with other values.' );
|
|
370
402
|
|
|
371
403
|
}
|
|
372
404
|
|
|
373
|
-
/** @param {NativeUniformValue} value @
|
|
374
|
-
function
|
|
405
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Matrix4} */
|
|
406
|
+
function matrix4ArrayElement( value, index ) {
|
|
407
|
+
|
|
408
|
+
\tif ( Array.isArray( value ) ) {
|
|
409
|
+
|
|
410
|
+
\t\tconst element = value[ index ];
|
|
411
|
+
|
|
412
|
+
\t\tif ( element instanceof Matrix4 ) return element;
|
|
375
413
|
|
|
376
|
-
\
|
|
414
|
+
\t}
|
|
415
|
+
|
|
416
|
+
\tthrow new Error( 'THREE.UniformsUtils: a uniform array mixes Matrix4 with other values.' );
|
|
377
417
|
|
|
378
418
|
}
|
|
379
419
|
|
|
380
|
-
/** @param {NativeUniformValue} value @
|
|
381
|
-
|
|
420
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Texture|null} */
|
|
421
|
+
function textureArrayElement( value, index ) {
|
|
382
422
|
|
|
383
|
-
\tif (
|
|
423
|
+
\tif ( Array.isArray( value ) ) {
|
|
384
424
|
|
|
385
|
-
\tconst
|
|
425
|
+
\t\tconst element = value[ index ];
|
|
386
426
|
|
|
387
|
-
\
|
|
427
|
+
\t\tif ( element === null || element instanceof Texture ) return element;
|
|
428
|
+
|
|
429
|
+
\t}
|
|
430
|
+
|
|
431
|
+
\tthrow new Error( 'THREE.UniformsUtils: a uniform array mixes textures with other values.' );
|
|
388
432
|
|
|
389
433
|
}
|
|
390
434
|
|
|
@@ -423,63 +467,70 @@ export function cloneUniformValue( value ) {
|
|
|
423
467
|
|
|
424
468
|
\tif ( isUniformNumberArray( value ) ) return value.slice();
|
|
425
469
|
|
|
426
|
-
\tif (
|
|
470
|
+
\tif ( Array.isArray( value ) && value.length > 0 ) {
|
|
427
471
|
|
|
428
|
-
\t\
|
|
429
|
-
\t\tconst
|
|
472
|
+
\t\tconst first = value[ 0 ];
|
|
473
|
+
\t\tconst length = value.length;
|
|
430
474
|
|
|
431
|
-
\t\
|
|
475
|
+
\t\tif ( first instanceof Vector2 ) {
|
|
432
476
|
|
|
433
|
-
\t\
|
|
477
|
+
\t\t\t/** @type {Vector2[]} */
|
|
478
|
+
\t\t\tconst cloned = [];
|
|
434
479
|
|
|
435
|
-
\t
|
|
480
|
+
\t\t\tfor ( let i = 0; i < length; i ++ ) cloned.push( vector2ArrayElement( value, i ).clone() );
|
|
481
|
+
|
|
482
|
+
\t\t\treturn cloned;
|
|
436
483
|
|
|
437
|
-
\
|
|
484
|
+
\t\t}
|
|
438
485
|
|
|
439
|
-
\t\
|
|
440
|
-
\t\tconst cloned = [];
|
|
486
|
+
\t\tif ( first instanceof Vector3 ) {
|
|
441
487
|
|
|
442
|
-
\t\
|
|
488
|
+
\t\t\t/** @type {Vector3[]} */
|
|
489
|
+
\t\t\tconst cloned = [];
|
|
443
490
|
|
|
444
|
-
\t\
|
|
491
|
+
\t\t\tfor ( let i = 0; i < length; i ++ ) cloned.push( vector3ArrayElement( value, i ).clone() );
|
|
445
492
|
|
|
446
|
-
\t
|
|
493
|
+
\t\t\treturn cloned;
|
|
447
494
|
|
|
448
|
-
\
|
|
495
|
+
\t\t}
|
|
449
496
|
|
|
450
|
-
\t\
|
|
451
|
-
\t\tconst cloned = [];
|
|
497
|
+
\t\tif ( first instanceof Vector4 ) {
|
|
452
498
|
|
|
453
|
-
\t\
|
|
499
|
+
\t\t\t/** @type {Vector4[]} */
|
|
500
|
+
\t\t\tconst cloned = [];
|
|
454
501
|
|
|
455
|
-
\t\
|
|
502
|
+
\t\t\tfor ( let i = 0; i < length; i ++ ) cloned.push( vector4ArrayElement( value, i ).clone() );
|
|
456
503
|
|
|
457
|
-
\t
|
|
504
|
+
\t\t\treturn cloned;
|
|
458
505
|
|
|
459
|
-
\
|
|
506
|
+
\t\t}
|
|
460
507
|
|
|
461
|
-
\t\
|
|
462
|
-
\t\tconst cloned = [];
|
|
508
|
+
\t\tif ( first instanceof Matrix4 ) {
|
|
463
509
|
|
|
464
|
-
\t\
|
|
510
|
+
\t\t\t/** @type {Matrix4[]} */
|
|
511
|
+
\t\t\tconst cloned = [];
|
|
465
512
|
|
|
466
|
-
\t\
|
|
513
|
+
\t\t\tfor ( let i = 0; i < length; i ++ ) cloned.push( matrix4ArrayElement( value, i ).clone() );
|
|
467
514
|
|
|
468
|
-
\t
|
|
515
|
+
\t\t\treturn cloned;
|
|
516
|
+
|
|
517
|
+
\t\t}
|
|
469
518
|
|
|
470
|
-
\tif (
|
|
519
|
+
\t\tif ( first === null || first instanceof Texture ) {
|
|
471
520
|
|
|
472
|
-
\t\t/** @type {Array<Texture|null>} */
|
|
473
|
-
\t\tconst cloned = [];
|
|
521
|
+
\t\t\t/** @type {Array<Texture|null>} */
|
|
522
|
+
\t\t\tconst cloned = [];
|
|
474
523
|
|
|
475
|
-
\t\tfor ( let i = 0
|
|
524
|
+
\t\t\tfor ( let i = 0; i < length; i ++ ) {
|
|
476
525
|
|
|
477
|
-
\t\t\tconst texture = value
|
|
478
|
-
\t\t\tcloned.push( texture === null ? null : texture.clone() );
|
|
526
|
+
\t\t\t\tconst texture = textureArrayElement( value, i );
|
|
527
|
+
\t\t\t\tcloned.push( texture === null ? null : texture.clone() );
|
|
479
528
|
|
|
480
|
-
\t\t}
|
|
529
|
+
\t\t\t}
|
|
481
530
|
|
|
482
|
-
\t\treturn cloned;
|
|
531
|
+
\t\t\treturn cloned;
|
|
532
|
+
|
|
533
|
+
\t\t}
|
|
483
534
|
|
|
484
535
|
\t}
|
|
485
536
|
|
|
@@ -856,8 +907,7 @@ function ${name}( gl, v, textures ) {
|
|
|
856
907
|
|
|
857
908
|
\t}
|
|
858
909
|
|
|
859
|
-
\tconst
|
|
860
|
-
\tconst n = list.length;
|
|
910
|
+
\tconst n = requireTextureArrayLength( v );
|
|
861
911
|
|
|
862
912
|
\tconst units = allocTexUnits( manager, n );
|
|
863
913
|
|
|
@@ -887,7 +937,7 @@ ${
|
|
|
887
937
|
}
|
|
888
938
|
\tfor ( let i = 0; i !== n; ++ i ) {
|
|
889
939
|
|
|
890
|
-
\t\tconst texture =
|
|
940
|
+
\t\tconst texture = textureArrayElement( v, i );
|
|
891
941
|
\t\tmanager.${setter}( texture === null ? ${shadowAware ? 'emptyTexture2D' : empty} : texture, units[ i ] );
|
|
892
942
|
|
|
893
943
|
\t}
|
|
@@ -1033,7 +1083,7 @@ import { Matrix4 } from '../../math/Matrix4.js';
|
|
|
1033
1083
|
import { Vector2 } from '../../math/Vector2.js';
|
|
1034
1084
|
import { Vector3 } from '../../math/Vector3.js';
|
|
1035
1085
|
import { Vector4 } from '../../math/Vector4.js';
|
|
1036
|
-
import { isUniformNumberArray
|
|
1086
|
+
import { isUniformNumberArray } from '../shaders/UniformsUtils.js';
|
|
1037
1087
|
import {
|
|
1038
1088
|
${nativeLightUniformClassNames.map((name) => `\t${name},`).join('\n')}
|
|
1039
1089
|
} from '../shaders/UniformsLib.js';
|
|
@@ -1124,10 +1174,39 @@ function requireUintUniformArray( value ) {
|
|
|
1124
1174
|
|
|
1125
1175
|
}
|
|
1126
1176
|
|
|
1127
|
-
/**
|
|
1128
|
-
|
|
1177
|
+
/**
|
|
1178
|
+
* A sampler array value is read element by element, never returned as a
|
|
1179
|
+
* narrowed \`Array<Texture|null>\`: a call site can hand the setter a value whose
|
|
1180
|
+
* static carrier is another array arm (a \`number[]\` passed to \`setValue\` by
|
|
1181
|
+
* name), and claiming that array for the texture arm is an array-to-array
|
|
1182
|
+
* conversion with no runtime form. Validated up front, as before, so a value
|
|
1183
|
+
* that is not a texture array throws before any texture unit is allocated.
|
|
1184
|
+
* @param {NativeUniformValue} value @return {number}
|
|
1185
|
+
*/
|
|
1186
|
+
function requireTextureArrayLength( value ) {
|
|
1187
|
+
|
|
1188
|
+
\tif ( Array.isArray( value ) && value.length > 0 ) {
|
|
1189
|
+
|
|
1190
|
+
\t\tconst first = value[ 0 ];
|
|
1191
|
+
|
|
1192
|
+
\t\tif ( first === null || first instanceof Texture ) return value.length;
|
|
1193
|
+
|
|
1194
|
+
\t}
|
|
1195
|
+
|
|
1196
|
+
\tthrow new Error( 'THREE.WebGLUniforms: sampler array uniform value must be an array of textures.' );
|
|
1197
|
+
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/** @param {NativeUniformValue} value @param {number} index @return {Texture|null} */
|
|
1201
|
+
function textureArrayElement( value, index ) {
|
|
1202
|
+
|
|
1203
|
+
\tif ( Array.isArray( value ) ) {
|
|
1129
1204
|
|
|
1130
|
-
\
|
|
1205
|
+
\t\tconst element = value[ index ];
|
|
1206
|
+
|
|
1207
|
+
\t\tif ( element === null || element instanceof Texture ) return element;
|
|
1208
|
+
|
|
1209
|
+
\t}
|
|
1131
1210
|
|
|
1132
1211
|
\tthrow new Error( 'THREE.WebGLUniforms: sampler array uniform value must be an array of textures.' );
|
|
1133
1212
|
|
package/geatsc-plugin.mjs
CHANGED
|
@@ -678,7 +678,7 @@ inline double gea_three_resource_read_native(std::string name, const gea::Ref<ge
|
|
|
678
678
|
"threeWebGLDrawBuffers",
|
|
679
679
|
"gea_three_webgl_draw_buffers",
|
|
680
680
|
"void",
|
|
681
|
-
'extern "C" void gea_three_webgl_draw_buffers(double
|
|
681
|
+
'extern "C" void gea_three_webgl_draw_buffers(double count, double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7);',
|
|
682
682
|
],
|
|
683
683
|
|
|
684
684
|
[
|
|
@@ -2327,8 +2327,11 @@ extern "C" void gea_three_webgl_renderbuffer_storage(double target, double inter
|
|
|
2327
2327
|
geaTrapCheck("gea_three_webgl_renderbuffer_storage"); GEA_WEBGL_VOID("renderbufferStorage"); gWebGL.glRenderbufferStorage(asGLenum(target), asGLenum(internalFormat), asGLsizei(width), asGLsizei(height)); }
|
|
2328
2328
|
extern "C" void gea_three_webgl_framebuffer_renderbuffer(double target, double attachment, double renderbuffertarget, double renderbuffer) {
|
|
2329
2329
|
geaTrapCheck("gea_three_webgl_framebuffer_renderbuffer"); GEA_WEBGL_VOID("framebufferRenderbuffer"); gWebGL.glFramebufferRenderbuffer(asGLenum(target), asGLenum(attachment), asGLenum(renderbuffertarget), asGLuint(renderbuffer)); }
|
|
2330
|
-
extern "C" void gea_three_webgl_draw_buffers(double
|
|
2331
|
-
geaTrapCheck("gea_three_webgl_draw_buffers"); GEA_WEBGL_VOID("drawBuffers");
|
|
2330
|
+
extern "C" void gea_three_webgl_draw_buffers(double count, double a0, double a1, double a2, double a3, double a4, double a5, double a6, double a7) {
|
|
2331
|
+
geaTrapCheck("gea_three_webgl_draw_buffers"); GEA_WEBGL_VOID("drawBuffers");
|
|
2332
|
+
const GLenum attachments[8] = {asGLenum(a0), asGLenum(a1), asGLenum(a2), asGLenum(a3), asGLenum(a4), asGLenum(a5), asGLenum(a6), asGLenum(a7)};
|
|
2333
|
+
const GLsizei n = std::max<GLsizei>(0, std::min<GLsizei>(asGLsizei(count), 8));
|
|
2334
|
+
gWebGL.glDrawBuffers(n, attachments); }
|
|
2332
2335
|
|
|
2333
2336
|
extern "C" void gea_three_webgl_clear_color(double r, double g, double b, double a) {
|
|
2334
2337
|
geaTrapCheck("gea_three_webgl_clear_color"); GEA_WEBGL_VOID("clearColor");
|
package/package.json
CHANGED
package/src/nativeWebGL.ts
CHANGED
|
@@ -1213,7 +1213,12 @@ export class NativeWebGL2RenderingContext {
|
|
|
1213
1213
|
framebufferTextureLayer(target: number, attachment: number, texture: NativeHandle | null, level: number, layer: number): void {
|
|
1214
1214
|
threeWebGLFramebufferTextureLayer(target, attachment, nullableNativeHandle(texture), level, layer)
|
|
1215
1215
|
}
|
|
1216
|
-
|
|
1216
|
+
/** Every listed buffer reaches GL (up to 8, the MRT limit the host passes), so multiple render targets write all their attachments. */
|
|
1217
|
+
drawBuffers(buffers: number[]): void {
|
|
1218
|
+
const count = Math.min(buffers.length, 8)
|
|
1219
|
+
const at = (index: number): number => index < count ? buffers[index] : this.NONE
|
|
1220
|
+
nativeWebGLDrawBuffers(count, at(0), at(1), at(2), at(3), at(4), at(5), at(6), at(7))
|
|
1221
|
+
}
|
|
1217
1222
|
|
|
1218
1223
|
clearColor(r: number, g: number, b: number, a: number): void { nativeWebGLClearColor(r, g, b, a) }
|
|
1219
1224
|
clear(mask: number): void { nativeWebGLClear(mask) }
|
package/src/nativeWebGLHost.ts
CHANGED
|
@@ -148,7 +148,7 @@ export function nativeWebGLBindRenderbuffer(target: number, renderbuffer: number
|
|
|
148
148
|
export function nativeWebGLDeleteRenderbuffer(renderbuffer: number): void { threeWebGLDeleteRenderbuffer(renderbuffer) }
|
|
149
149
|
export function nativeWebGLRenderbufferStorage(target: number, internalFormat: number, width: number, height: number): void { threeWebGLRenderbufferStorage(target, internalFormat, width, height) }
|
|
150
150
|
export function nativeWebGLFramebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: number): void { threeWebGLFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer) }
|
|
151
|
-
export function nativeWebGLDrawBuffers(
|
|
151
|
+
export function nativeWebGLDrawBuffers(count: number, a0: number, a1: number, a2: number, a3: number, a4: number, a5: number, a6: number, a7: number): void { threeWebGLDrawBuffers(count, a0, a1, a2, a3, a4, a5, a6, a7) }
|
|
152
152
|
|
|
153
153
|
export function nativeWebGLClearColor(r: number, g: number, b: number, a: number): void { threeWebGLClearColor(r, g, b, a) }
|
|
154
154
|
export function nativeWebGLClear(mask: number): void { threeWebGLClear(mask) }
|
|
@@ -303,7 +303,7 @@ declare function threeWebGLRenderbufferStorage(target: number, internalFormat: n
|
|
|
303
303
|
/** @gea-host-inert Native state only; retains no script references and invokes no script. */
|
|
304
304
|
declare function threeWebGLFramebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: number): void
|
|
305
305
|
/** @gea-host-inert Native state only; retains no script references and invokes no script. */
|
|
306
|
-
declare function threeWebGLDrawBuffers(
|
|
306
|
+
declare function threeWebGLDrawBuffers(count: number, a0: number, a1: number, a2: number, a3: number, a4: number, a5: number, a6: number, a7: number): void
|
|
307
307
|
/** @gea-host-inert Copies scalar arguments into GL state; retains no script references and invokes no script. */
|
|
308
308
|
declare function threeWebGLClearColor(r: number, g: number, b: number, a: number): void
|
|
309
309
|
/** @gea-host-inert Native state only; retains no script references and invokes no script. */
|