@idetik/core 0.27.0 → 0.27.1
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.d.ts +2 -0
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +13 -13
- package/dist/index.umd.cjs.map +1 -1
- package/dist/types/src/core/renderer.d.ts +3 -0
- package/dist/types/src/core/renderer.d.ts.map +1 -1
- package/dist/types/src/renderers/webgl_renderer.d.ts +3 -0
- package/dist/types/src/renderers/webgl_renderer.d.ts.map +1 -1
- package/dist/types/src/renderers/webgl_textures.d.ts +2 -1
- package/dist/types/src/renderers/webgl_textures.d.ts.map +1 -1
- package/dist/types/src/renderers/webgpu/webgpu_renderer.d.ts +3 -0
- package/dist/types/src/renderers/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/dist/types/src/renderers/webgpu/webgpu_texture_pool.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -566,6 +566,8 @@ declare abstract class Renderer {
|
|
|
566
566
|
get renderedObjects(): number;
|
|
567
567
|
abstract get gpuTextureBytes(): number;
|
|
568
568
|
abstract get gpuTextureCount(): number;
|
|
569
|
+
abstract uploadTexture(texture: Texture): void;
|
|
570
|
+
abstract disposeTexture(texture: Texture): void;
|
|
569
571
|
set backgroundColor(color: ColorLike);
|
|
570
572
|
}
|
|
571
573
|
|
package/dist/index.js
CHANGED
|
@@ -1267,13 +1267,8 @@ class ti {
|
|
|
1267
1267
|
throw new Error(
|
|
1268
1268
|
`Texture index ${I} must be in [0, ${this.maxTextureUnits_ - 1}]`
|
|
1269
1269
|
);
|
|
1270
|
-
this.
|
|
1271
|
-
|
|
1272
|
-
this.textures_.has(A) || this.generateTexture(A, B, g);
|
|
1273
|
-
const Q = this.textures_.get(A);
|
|
1274
|
-
if (!Q)
|
|
1275
|
-
throw new Error("Failed to retrieve texture ID");
|
|
1276
|
-
this.gl_.bindTexture(g, Q), A.needsUpdate && A.data !== null && (this.configureTextureParameters(A, g), this.uploadTextureData(A, B, g), A.needsUpdate = !1), this.currentTexture_ = A;
|
|
1270
|
+
const g = this.textures_.get(A);
|
|
1271
|
+
g && !A.needsUpdate ? (this.gl_.activeTexture(this.gl_.TEXTURE0 + I), this.gl_.bindTexture(this.getTextureType(A), g)) : this.uploadTexture(A, I), this.currentTexture_ = A;
|
|
1277
1272
|
}
|
|
1278
1273
|
readTexel(A, I, g, B) {
|
|
1279
1274
|
const Q = this.gl_, E = this.textures_.get(A);
|
|
@@ -1312,7 +1307,18 @@ class ti {
|
|
|
1312
1307
|
return { format: I.RGBA, type: I.FLOAT, out: new Float32Array(4) };
|
|
1313
1308
|
}
|
|
1314
1309
|
}
|
|
1315
|
-
|
|
1310
|
+
uploadTexture(A, I = 0) {
|
|
1311
|
+
if (this.textures_.has(A) && !A.needsUpdate) return;
|
|
1312
|
+
if (A.data === null)
|
|
1313
|
+
throw new Error("Cannot upload a texture that has no CPU data");
|
|
1314
|
+
const g = this.getTextureType(A), B = this.getDataFormatInfo(A.dataFormat, A.dataType);
|
|
1315
|
+
this.gl_.activeTexture(this.gl_.TEXTURE0 + I), this.textures_.has(A) || this.generateTexture(A, B, g);
|
|
1316
|
+
const Q = this.textures_.get(A);
|
|
1317
|
+
if (!Q)
|
|
1318
|
+
throw new Error("Failed to retrieve texture ID");
|
|
1319
|
+
this.gl_.bindTexture(g, Q), this.configureTextureParameters(A, g), this.uploadTextureData(A, B, g), A.needsUpdate = !1;
|
|
1320
|
+
}
|
|
1321
|
+
dispose(A) {
|
|
1316
1322
|
const I = this.textures_.get(A);
|
|
1317
1323
|
if (I) {
|
|
1318
1324
|
this.gl_.deleteTexture(I), this.textures_.delete(A), A.readTexel = void 0, this.currentTexture_ === A && (this.currentTexture_ = null);
|
|
@@ -1322,7 +1328,7 @@ class ti {
|
|
|
1322
1328
|
}
|
|
1323
1329
|
disposeAll() {
|
|
1324
1330
|
for (const A of Array.from(this.textures_.keys()))
|
|
1325
|
-
this.
|
|
1331
|
+
this.dispose(A);
|
|
1326
1332
|
this.gpuTextureBytes_ = 0, this.textureCount_ = 0;
|
|
1327
1333
|
}
|
|
1328
1334
|
alreadyActive(A) {
|
|
@@ -1740,7 +1746,7 @@ class eC extends cQ {
|
|
|
1740
1746
|
renderObject(A, I, g) {
|
|
1741
1747
|
const B = A.objects[I];
|
|
1742
1748
|
if (B.popStaleTextures().forEach((E) => {
|
|
1743
|
-
this.textures_.
|
|
1749
|
+
this.textures_.dispose(E);
|
|
1744
1750
|
}), !B.programName) return;
|
|
1745
1751
|
this.state_.setCullFaceMode(B.cullFaceMode), this.state_.setDepthTesting(B.depthTest), this.state_.setDepthMask(B.depthTest), this.bindings_.bindGeometry(B.geometry), B.textures.forEach((E, i) => {
|
|
1746
1752
|
this.textures_.bindTexture(E, i);
|
|
@@ -1810,6 +1816,12 @@ class eC extends cQ {
|
|
|
1810
1816
|
const n = this.glGetPrimitive(A.primitive), D = A.indexData;
|
|
1811
1817
|
D.length ? this.gl_.drawElements(n, D.length, this.gl_.UNSIGNED_INT, 0) : this.gl_.drawArrays(n, 0, A.vertexCount);
|
|
1812
1818
|
}
|
|
1819
|
+
uploadTexture(A) {
|
|
1820
|
+
this.textures_.uploadTexture(A);
|
|
1821
|
+
}
|
|
1822
|
+
disposeTexture(A) {
|
|
1823
|
+
this.textures_.dispose(A);
|
|
1824
|
+
}
|
|
1813
1825
|
glGetPrimitive(A) {
|
|
1814
1826
|
switch (A) {
|
|
1815
1827
|
case "points":
|
|
@@ -2160,16 +2172,20 @@ class ki {
|
|
|
2160
2172
|
this.device_ = A, this.textures_ = [];
|
|
2161
2173
|
}
|
|
2162
2174
|
get(A) {
|
|
2163
|
-
|
|
2164
|
-
if (I)
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2175
|
+
let I = this.textures_.find((g) => g.entry === A);
|
|
2176
|
+
if (I && !A.needsUpdate) return I.texture;
|
|
2177
|
+
if (A.data === null)
|
|
2178
|
+
throw new Error("Cannot upload a texture that has no CPU data");
|
|
2179
|
+
if (!I) {
|
|
2180
|
+
const g = this.device_.createTexture({
|
|
2181
|
+
size: nC(A),
|
|
2182
|
+
dimension: A instanceof TA ? "3d" : "2d",
|
|
2183
|
+
format: di(A),
|
|
2184
|
+
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC
|
|
2185
|
+
});
|
|
2186
|
+
this.textures_.push({ entry: A, texture: g }), I = this.textures_[this.textures_.length - 1];
|
|
2187
|
+
}
|
|
2188
|
+
return this.upload(A, I.texture), A.readTexel = (g, B, Q) => this.readTexel(I.texture, A.dataType, g, B, Q), I.texture;
|
|
2173
2189
|
}
|
|
2174
2190
|
async readTexel(A, I, g, B, Q) {
|
|
2175
2191
|
const E = this.device_.createBuffer({
|
|
@@ -8582,6 +8598,12 @@ class Mo extends cQ {
|
|
|
8582
8598
|
}
|
|
8583
8599
|
clear() {
|
|
8584
8600
|
}
|
|
8601
|
+
uploadTexture(A) {
|
|
8602
|
+
this.texturePool_.get(A);
|
|
8603
|
+
}
|
|
8604
|
+
disposeTexture(A) {
|
|
8605
|
+
this.texturePool_.dispose(A);
|
|
8606
|
+
}
|
|
8585
8607
|
setUniformsForObject(A, I, g) {
|
|
8586
8608
|
_A(
|
|
8587
8609
|
this.currentModelView_,
|