@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.js 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
  'use strict';
@@ -158,21 +158,48 @@ var GPUBufferOptionsMemoryShared = 1 << 1;
158
158
  var _a$6, _b$3;
159
159
  // @ts-expect-error safe to assign
160
160
  var constants = {};
161
- {
162
- if (typeof WebGL2RenderingContext === 'function') {
163
- copy(WebGL2RenderingContext);
164
- }
165
- else if (typeof WebGLRenderingContext !== 'undefined') {
166
- copy(WebGLRenderingContext);
167
- copy(WebGLRenderingContext.prototype);
168
- }
169
- else {
170
- //ios 16 lockdown mode
171
- consoleError('WebGL not in global');
172
- }
161
+ if (typeof WebGL2RenderingContext === 'function') {
162
+ copy(WebGL2RenderingContext);
173
163
  }
174
- // @ts-expect-error set default value
175
- constants['HALF_FLOAT'] = 5131;
164
+ else if (typeof WebGLRenderingContext !== 'undefined') {
165
+ copy(WebGLRenderingContext);
166
+ copy(WebGLRenderingContext.prototype);
167
+ }
168
+ else {
169
+ //ios 16 lockdown mode
170
+ consoleError('WebGL not in global');
171
+ }
172
+ Object.assign(constants, {
173
+ HALF_FLOAT: 5131,
174
+ COMPRESSED_RGBA_ASTC_4x4_KHR: 0x93B0,
175
+ COMPRESSED_RGBA_ASTC_5x4_KHR: 0x93B1,
176
+ COMPRESSED_RGBA_ASTC_5x5_KHR: 0x93B2,
177
+ COMPRESSED_RGBA_ASTC_6x5_KHR: 0x93B3,
178
+ COMPRESSED_RGBA_ASTC_6x6_KHR: 0x93B4,
179
+ COMPRESSED_RGBA_ASTC_8x5_KHR: 0x93B5,
180
+ COMPRESSED_RGBA_ASTC_8x6_KHR: 0x93B6,
181
+ COMPRESSED_RGBA_ASTC_8x8_KHR: 0x93B7,
182
+ COMPRESSED_RGBA_ASTC_10x5_KHR: 0x93B8,
183
+ COMPRESSED_RGBA_ASTC_10x6_KHR: 0x93B9,
184
+ COMPRESSED_RGBA_ASTC_10x8_KHR: 0x93BA,
185
+ COMPRESSED_RGBA_ASTC_10x10_KHR: 0x93BB,
186
+ COMPRESSED_RGBA_ASTC_12x10_KHR: 0x93BC,
187
+ COMPRESSED_RGBA_ASTC_12x12_KHR: 0x93BD,
188
+ COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: 0x93D0,
189
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: 0x93D1,
190
+ COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: 0x93D2,
191
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: 0x93D3,
192
+ COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: 0x93D4,
193
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: 0x93D5,
194
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: 0x93D6,
195
+ COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: 0x93D7,
196
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: 0x93D8,
197
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: 0x93D9,
198
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: 0x93DA,
199
+ COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: 0x93DB,
200
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: 0x93DC,
201
+ COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: 0x93DD,
202
+ });
176
203
  function copy(target) {
177
204
  for (var name_1 in target) {
178
205
  if (/^[A-Z_]/.test(name_1)) {
@@ -1795,13 +1822,18 @@ var GLProgram = /** @class */ (function () {
1795
1822
  }
1796
1823
  };
1797
1824
  GLProgram.prototype.getSemanticValue = function (state, semanticName) {
1798
- var renderPassSemantics = state.currentPass.semantics;
1799
- var renderFrameSemantics = state.currentFrame.semantics;
1800
- if (renderPassSemantics.hasSemanticValue(semanticName)) {
1801
- return renderPassSemantics.getSemanticValue(semanticName, state);
1825
+ if (typeof semanticName === 'function') {
1826
+ return semanticName(state);
1802
1827
  }
1803
- else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1804
- return renderFrameSemantics.getSemanticValue(semanticName, state);
1828
+ else {
1829
+ var renderPassSemantics = state.currentPass.semantics;
1830
+ var renderFrameSemantics = state.currentFrame.semantics;
1831
+ if (renderPassSemantics.hasSemanticValue(semanticName)) {
1832
+ return renderPassSemantics.getSemanticValue(semanticName, state);
1833
+ }
1834
+ else if (renderFrameSemantics.hasSemanticValue(semanticName)) {
1835
+ return renderFrameSemantics.getSemanticValue(semanticName, state);
1836
+ }
1805
1837
  }
1806
1838
  };
1807
1839
  GLProgram.prototype.setupUniforms = function (state) {
@@ -3120,7 +3152,14 @@ var PredyResourceCacheStatus;
3120
3152
  PredyResourceCacheStatus[PredyResourceCacheStatus["noCache"] = 0] = "noCache";
3121
3153
  PredyResourceCacheStatus[PredyResourceCacheStatus["cached"] = 1] = "cached";
3122
3154
  PredyResourceCacheStatus[PredyResourceCacheStatus["preloaded"] = 2] = "preloaded";
3155
+ PredyResourceCacheStatus[PredyResourceCacheStatus["hitCDN"] = 3] = "hitCDN";
3156
+ PredyResourceCacheStatus[PredyResourceCacheStatus["missCDN"] = 4] = "missCDN";
3123
3157
  })(PredyResourceCacheStatus || (PredyResourceCacheStatus = {}));
3158
+ var PredyTextEncoding;
3159
+ (function (PredyTextEncoding) {
3160
+ PredyTextEncoding[PredyTextEncoding["utf8"] = 0] = "utf8";
3161
+ PredyTextEncoding[PredyTextEncoding["ascii"] = 1] = "ascii";
3162
+ })(PredyTextEncoding || (PredyTextEncoding = {}));
3124
3163
 
3125
3164
  var GLRenderBuffer = /** @class */ (function () {
3126
3165
  function GLRenderBuffer(renderer, options) {
@@ -3574,7 +3613,7 @@ var COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
3574
3613
  var TEX_2D = 2; // uses a gl.texImage2D()
3575
3614
  //const TEX_3D = 3; // uses a gl.texImage3D()
3576
3615
  var KhronosTextureContainer = /** @class */ (function () {
3577
- function KhronosTextureContainer(arrayBuffer, facesExpected, baseOffset) {
3616
+ function KhronosTextureContainer(arrayBuffer, baseOffset) {
3578
3617
  if (baseOffset === void 0) { baseOffset = 0; }
3579
3618
  this.arrayBuffer = arrayBuffer;
3580
3619
  this.baseOffset = baseOffset;
@@ -3594,9 +3633,9 @@ var KhronosTextureContainer = /** @class */ (function () {
3594
3633
  identifier[9] !== 0x0a ||
3595
3634
  identifier[10] !== 0x1a ||
3596
3635
  identifier[11] !== 0x0a) {
3597
- throw Error('texture missing KTX identifier');
3636
+ throw Error('texture missing KTX 1.1 identifier');
3598
3637
  }
3599
- // load the reset of the header in native-ri 32 bit uint
3638
+ // load the reset of the header in native 32 bit uint
3600
3639
  var dataSize = Uint32Array.BYTES_PER_ELEMENT;
3601
3640
  var headerDataView = new DataView(this.arrayBuffer, this.baseOffset + 12, 13 * dataSize);
3602
3641
  var endianness = headerDataView.getUint32(0, true);
@@ -3616,15 +3655,11 @@ var KhronosTextureContainer = /** @class */ (function () {
3616
3655
  // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
3617
3656
  this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
3618
3657
  if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
3619
- consoleWarn('only 2D textures currently supported');
3658
+ //consoleWarn('only 2D textures currently supported');
3620
3659
  return;
3621
3660
  }
3622
3661
  if (this.numberOfArrayElements !== 0) {
3623
- consoleWarn('texture arrays not currently supported');
3624
- return;
3625
- }
3626
- if (this.numberOfFaces !== facesExpected) {
3627
- consoleWarn('number of faces expected' + facesExpected + ', but found ' + this.numberOfFaces);
3662
+ //consoleWarn('texture arrays not currently supported');
3628
3663
  return;
3629
3664
  }
3630
3665
  // we now have a completely validated file, so could use existence of loadType as success
@@ -3663,14 +3698,14 @@ var KhronosTextureContainer = /** @class */ (function () {
3663
3698
  return KhronosTextureContainer;
3664
3699
  }());
3665
3700
  function getCompressedTextureOptions(data) {
3666
- var ktx = new KhronosTextureContainer(data, 1);
3701
+ var ktx = new KhronosTextureContainer(data);
3667
3702
  var useMipmaps = ktx.numberOfMipmapLevels >= Math.floor(Math.log2(Math.max(ktx.pixelWidth, ktx.pixelHeight)) + 1);
3668
3703
  return {
3669
3704
  sourceType: exports.TextureSourceType.compressed,
3670
- type: ktx.glType,
3705
+ type: constants.UNSIGNED_BYTE,
3671
3706
  target: ktx.numberOfFaces === 6 ? constants.TEXTURE_CUBE_MAP : constants.TEXTURE_2D,
3707
+ format: ktx.glInternalFormat,
3672
3708
  internalFormat: ktx.glInternalFormat,
3673
- format: ktx.glFormat,
3674
3709
  mipmaps: ktx.mipmaps(useMipmaps),
3675
3710
  };
3676
3711
  }
@@ -4486,10 +4521,10 @@ var GLMaterial = /** @class */ (function () {
4486
4521
  webGLState.depthFunc(currentState.depthFunc);
4487
4522
  webGLState.depthRange((_a = currentState.depthRange) === null || _a === void 0 ? void 0 : _a[0], (_b = currentState.depthRange) === null || _b === void 0 ? void 0 : _b[1]);
4488
4523
  }
4524
+ webGLState.frontFace(currentState.frontFace);
4489
4525
  if (currentState.cullFaceEnabled) {
4490
4526
  //face
4491
4527
  webGLState.cullFace(currentState.cullFace);
4492
- webGLState.frontFace(currentState.frontFace);
4493
4528
  }
4494
4529
  if (currentState.polygonOffsetFill) {
4495
4530
  var polygonOffset = currentState.polygonOffset || [0, 0];
@@ -5780,6 +5815,8 @@ var MarsRenderer = /** @class */ (function () {
5780
5815
  MarsRenderer.prototype.cancelAnimationFrame = function (id) {
5781
5816
  return window.cancelAnimationFrame(id);
5782
5817
  };
5818
+ MarsRenderer.prototype.resume = function () {
5819
+ };
5783
5820
  MarsRenderer.prototype.getErrors = function () {
5784
5821
  var gl = this.internal.gl;
5785
5822
  var err = gl.getError();
@@ -5860,7 +5897,7 @@ var MarsSharedGeometry = /** @class */ (function (_super) {
5860
5897
  return MarsSharedGeometry;
5861
5898
  }(MarsGeometry));
5862
5899
 
5863
- consoleLog('version: ' + "0.3.0-beta.99");
5900
+ consoleLog('version: ' + "0.3.0");
5864
5901
  var ModuleMsg = 'RI Package: @predy-js/render-interface';
5865
5902
 
5866
5903
  var RI = /*#__PURE__*/Object.freeze({