[threejs] Closes #1412, added dispose() method to SkeletonMesh and required underlying code.

This commit is contained in:
badlogic 2019-07-24 13:21:42 +02:00
parent 4a357f23f2
commit 2b5e521c34
9 changed files with 36 additions and 3 deletions

View File

@ -1807,6 +1807,7 @@ declare module spine.threejs {
private indices;
private indicesLength;
constructor(maxVertices?: number);
dispose(): void;
clear(): void;
begin(): void;
canBatch(verticesLength: number, indicesLength: number): boolean;
@ -1836,6 +1837,7 @@ declare module spine.threejs {
private tempColor;
constructor(skeletonData: SkeletonData);
update(deltaTime: number): void;
dispose(): void;
private clearBatches();
private nextBatch();
private updateGeometry();

View File

@ -11048,6 +11048,10 @@ var spine;
_this.material = new threejs.SkeletonMeshMaterial();
return _this;
}
MeshBatcher.prototype.dispose = function () {
this.geometry.dispose();
this.material.dispose();
};
MeshBatcher.prototype.clear = function () {
var geo = this.geometry;
geo.drawRange.start = 0;
@ -11159,6 +11163,11 @@ var spine;
skeleton.updateWorldTransform();
this.updateGeometry();
};
SkeletonMesh.prototype.dispose = function () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].dispose();
}
};
SkeletonMesh.prototype.clearBatches = function () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].clear();

File diff suppressed because one or more lines are too long

View File

@ -1341,6 +1341,7 @@ declare module spine.threejs {
private indices;
private indicesLength;
constructor(maxVertices?: number);
dispose(): void;
clear(): void;
begin(): void;
canBatch(verticesLength: number, indicesLength: number): boolean;
@ -1370,6 +1371,7 @@ declare module spine.threejs {
private tempColor;
constructor(skeletonData: SkeletonData);
update(deltaTime: number): void;
dispose(): void;
private clearBatches();
private nextBatch();
private updateGeometry();

View File

@ -8166,6 +8166,10 @@ var spine;
_this.material = new threejs.SkeletonMeshMaterial();
return _this;
}
MeshBatcher.prototype.dispose = function () {
this.geometry.dispose();
this.material.dispose();
};
MeshBatcher.prototype.clear = function () {
var geo = this.geometry;
geo.drawRange.start = 0;
@ -8277,6 +8281,11 @@ var spine;
skeleton.updateWorldTransform();
this.updateGeometry();
};
SkeletonMesh.prototype.dispose = function () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].dispose();
}
};
SkeletonMesh.prototype.clearBatches = function () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].clear();

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
<head>
<meta charset="UTF-8">
<title>spine-threejs</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r79/three.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/106/three.min.js"></script>
<script src="../../build/spine-threejs.js"></script>
</head>
<style>

View File

@ -55,6 +55,11 @@ module spine.threejs {
this.material = new SkeletonMeshMaterial();
}
dispose () {
this.geometry.dispose();
this.material.dispose();
}
clear () {
let geo = (<THREE.BufferGeometry>this.geometry);
geo.drawRange.start = 0;

View File

@ -102,6 +102,12 @@ module spine.threejs {
this.updateGeometry();
}
dispose () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].dispose();
}
}
private clearBatches () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].clear();