@predy-js/render-interface 0.3.0-beta.99 → 0.3.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/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.0-beta.99
5
+ * Version: v0.3.0
6
6
  */
7
7
 
8
8
  /******************************************************************************
@@ -154,21 +154,48 @@ var GPUBufferOptionsMemoryShared = 1 << 1;
154
154
  var _a$6, _b$3;
155
155
  // @ts-expect-error safe to assign
156
156
  var constants = {};
157
- {
158
- if (typeof WebGL2RenderingContext === 'function') {
159
- copy(WebGL2RenderingContext);
160
- }
161
- else if (typeof WebGLRenderingContext !== 'undefined') {
162
- copy(WebGLRenderingContext);
163
- copy(WebGLRenderingContext.prototype);
164
- }
165
- else {
166
- //ios 16 lockdown mode
167
- consoleError('WebGL not in global');
168
- }
157
+ if (typeof WebGL2RenderingContext === 'function') {
158
+ copy(WebGL2RenderingContext);
169
159
  }
170
- // @ts-expect-error set default value
171
- constants['HALF_FLOAT'] = 5131;
160
+ else if (typeof WebGLRenderingContext !== 'undefined') {
161
+ copy(WebGLRenderingContext);
162
+ copy(WebGLRenderingContext.prototype);
163
+ }
164
+ else {
165
+ //ios 16 lockdown mode
166
+ consoleError('WebGL not in global');
167
+ }
168
+ Object.assign(constants, {
169
+ HALF_FLOAT: 5131,
170
+ COMPRESSED_RGBA_ASTC_4x4_KHR: 0x93B0,
171
+ COMPRESSED_RGBA_ASTC_5x4_KHR: 0x93B1,
172
+ COMPRESSED_RGBA_ASTC_5x5_KHR: 0x93B2,
173
+ COMPRESSED_RGBA_ASTC_6x5_KHR: 0x93B3,
174
+ COMPRESSED_RGBA_ASTC_6x6_KHR: 0x93B4,
175
+ COMPRESSED_RGBA_ASTC_8x5_KHR: 0x93B5,
176
+ COMPRESSED_RGBA_ASTC_8x6_KHR: 0x93B6,
177
+ COMPRESSED_RGBA_ASTC_8x8_KHR: 0x93B7,
178
+ COMPRESSED_RGBA_ASTC_10x5_KHR: 0x93B8,
179
+ COMPRESSED_RGBA_ASTC_10x6_KHR: 0x93B9,
180
+ COMPRESSED_RGBA_ASTC_10x8_KHR: 0x93BA,
181
+ COMPRESSED_RGBA_ASTC_10x10_KHR: 0x93BB,
182
+ COMPRESSED_RGBA_ASTC_12x10_KHR: 0x93BC,
183
+ COMPRESSED_RGBA_ASTC_12x12_KHR: 0x93BD,
184
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: 0x93D0,
185
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: 0x93D1,
186
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: 0x93D2,
187
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: 0x93D3,
188
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: 0x93D4,
189
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: 0x93D5,
190
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: 0x93D6,
191
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: 0x93D7,
192
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: 0x93D8,
193
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: 0x93D9,
194
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: 0x93DA,
195
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: 0x93DB,
196
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: 0x93DC,
197
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: 0x93DD,
198
+ });
172
199
  function copy(target) {
173
200
  for (var name_1 in target) {
174
201
  if (/^[A-Z_]/.test(name_1)) {
@@ -1791,13 +1818,18 @@ var GLProgram = /** @class */ (function () {
1791
1818
  }
1792
1819
  };
1793
1820
  GLProgram.prototype.getSemanticValue = function (state, semanticName) {
1794
- var renderPassSemantics = state.currentPass.semantics;
1795
- var renderFrameSemantics = state.currentFrame.semantics;
1796
- if (renderPassSemantics.hasSemanticValue(semanticName)) {
1797
- return renderPassSemantics.getSemanticValue(semanticName, state);
1821
+ if (typeof semanticName === 'function') {
1822
+ return semanticName(state);
1798
1823
  }
1799
- else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1800
- return renderFrameSemantics.getSemanticValue(semanticName, state);
1824
+ else {
1825
+ var renderPassSemantics = state.currentPass.semantics;
1826
+ var renderFrameSemantics = state.currentFrame.semantics;
1827
+ if (renderPassSemantics.hasSemanticValue(semanticName)) {
1828
+ return renderPassSemantics.getSemanticValue(semanticName, state);
1829
+ }
1830
+ else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1831
+ return renderFrameSemantics.getSemanticValue(semanticName, state);
1832
+ }
1801
1833
  }
1802
1834
  };
1803
1835
  GLProgram.prototype.setupUniforms = function (state) {
@@ -3116,7 +3148,14 @@ var PredyResourceCacheStatus;
3116
3148
  PredyResourceCacheStatus[PredyResourceCacheStatus["noCache"] = 0] = "noCache";
3117
3149
  PredyResourceCacheStatus[PredyResourceCacheStatus["cached"] = 1] = "cached";
3118
3150
  PredyResourceCacheStatus[PredyResourceCacheStatus["preloaded"] = 2] = "preloaded";
3151
+ PredyResourceCacheStatus[PredyResourceCacheStatus["hitCDN"] = 3] = "hitCDN";
3152
+ PredyResourceCacheStatus[PredyResourceCacheStatus["missCDN"] = 4] = "missCDN";
3119
3153
  })(PredyResourceCacheStatus || (PredyResourceCacheStatus = {}));
3154
+ var PredyTextEncoding;
3155
+ (function (PredyTextEncoding) {
3156
+ PredyTextEncoding[PredyTextEncoding["utf8"] = 0] = "utf8";
3157
+ PredyTextEncoding[PredyTextEncoding["ascii"] = 1] = "ascii";
3158
+ })(PredyTextEncoding || (PredyTextEncoding = {}));
3120
3159
 
3121
3160
  var GLRenderBuffer = /** @class */ (function () {
3122
3161
  function GLRenderBuffer(renderer, options) {
@@ -3570,7 +3609,7 @@ var COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
3570
3609
  var TEX_2D = 2; // uses a gl.texImage2D()
3571
3610
  //const TEX_3D = 3; // uses a gl.texImage3D()
3572
3611
  var KhronosTextureContainer = /** @class */ (function () {
3573
- function KhronosTextureContainer(arrayBuffer, facesExpected, baseOffset) {
3612
+ function KhronosTextureContainer(arrayBuffer, baseOffset) {
3574
3613
  if (baseOffset === void 0) { baseOffset = 0; }
3575
3614
  this.arrayBuffer = arrayBuffer;
3576
3615
  this.baseOffset = baseOffset;
@@ -3590,9 +3629,9 @@ var KhronosTextureContainer = /** @class */ (function () {
3590
3629
  identifier[9] !== 0x0a ||
3591
3630
  identifier[10] !== 0x1a ||
3592
3631
  identifier[11] !== 0x0a) {
3593
- throw Error('texture missing KTX identifier');
3632
+ throw Error('texture missing KTX 1.1 identifier');
3594
3633
  }
3595
- // load the reset of the header in native-ri 32 bit uint
3634
+ // load the reset of the header in native 32 bit uint
3596
3635
  var dataSize = Uint32Array.BYTES_PER_ELEMENT;
3597
3636
  var headerDataView = new DataView(this.arrayBuffer, this.baseOffset + 12, 13 * dataSize);
3598
3637
  var endianness = headerDataView.getUint32(0, true);
@@ -3612,15 +3651,11 @@ var KhronosTextureContainer = /** @class */ (function () {
3612
3651
  // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
3613
3652
  this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
3614
3653
  if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
3615
- consoleWarn('only 2D textures currently supported');
3654
+ //consoleWarn('only 2D textures currently supported');
3616
3655
  return;
3617
3656
  }
3618
3657
  if (this.numberOfArrayElements !== 0) {
3619
- consoleWarn('texture arrays not currently supported');
3620
- return;
3621
- }
3622
- if (this.numberOfFaces !== facesExpected) {
3623
- consoleWarn('number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces);
3658
+ //consoleWarn('texture arrays not currently supported');
3624
3659
  return;
3625
3660
  }
3626
3661
  // we now have a completely validated file, so could use existence of loadType as success
@@ -3659,14 +3694,14 @@ var KhronosTextureContainer = /** @class */ (function () {
3659
3694
  return KhronosTextureContainer;
3660
3695
  }());
3661
3696
  function getCompressedTextureOptions(data) {
3662
- var ktx = new KhronosTextureContainer(data, 1);
3697
+ var ktx = new KhronosTextureContainer(data);
3663
3698
  var useMipmaps = ktx.numberOfMipmapLevels >= Math.floor(Math.log2(Math.max(ktx.pixelWidth, ktx.pixelHeight)) + 1);
3664
3699
  return {
3665
3700
  sourceType: TextureSourceType.compressed,
3666
- type: ktx.glType,
3701
+ type: constants.UNSIGNED_BYTE,
3667
3702
  target: ktx.numberOfFaces === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
3703
+ format: ktx.glInternalFormat,
3668
3704
  internalFormat: ktx.glInternalFormat,
3669
- format: ktx.glFormat,
3670
3705
  mipmaps: ktx.mipmaps(useMipmaps),
3671
3706
  };
3672
3707
  }
@@ -4482,10 +4517,10 @@ var GLMaterial = /** @class */ (function () {
4482
4517
  webGLState.depthFunc(currentState.depthFunc);
4483
4518
  webGLState.depthRange((_a = currentState.depthRange) === null || _a === void 0 ? void 0 : _a[0], (_b = currentState.depthRange) === null || _b === void 0 ? void 0 : _b[1]);
4484
4519
  }
4520
+ webGLState.frontFace(currentState.frontFace);
4485
4521
  if (currentState.cullFaceEnabled) {
4486
4522
  //face
4487
4523
  webGLState.cullFace(currentState.cullFace);
4488
- webGLState.frontFace(currentState.frontFace);
4489
4524
  }
4490
4525
  if (currentState.polygonOffsetFill) {
4491
4526
  var polygonOffset = currentState.polygonOffset || [0, 0];
@@ -5776,6 +5811,8 @@ var MarsRenderer = /** @class */ (function () {
5776
5811
  MarsRenderer.prototype.cancelAnimationFrame = function (id) {
5777
5812
  return window.cancelAnimationFrame(id);
5778
5813
  };
5814
+ MarsRenderer.prototype.resume = function () {
5815
+ };
5779
5816
  MarsRenderer.prototype.getErrors = function () {
5780
5817
  var gl = this.internal.gl;
5781
5818
  var err = gl.getError();
@@ -5856,7 +5893,7 @@ var MarsSharedGeometry = /** @class */ (function (_super) {
5856
5893
  return MarsSharedGeometry;
5857
5894
  }(MarsGeometry));
5858
5895
 
5859
- consoleLog('version: ' + "0.3.0-beta.99");
5896
+ consoleLog('version: ' + "0.3.0");
5860
5897
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
5861
5898
 
5862
5899
  var RI = /*#__PURE__*/Object.freeze({