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

View File

@ -11048,6 +11048,10 @@ var spine;
_this.material = new threejs.SkeletonMeshMaterial(); _this.material = new threejs.SkeletonMeshMaterial();
return _this; return _this;
} }
MeshBatcher.prototype.dispose = function () {
this.geometry.dispose();
this.material.dispose();
};
MeshBatcher.prototype.clear = function () { MeshBatcher.prototype.clear = function () {
var geo = this.geometry; var geo = this.geometry;
geo.drawRange.start = 0; geo.drawRange.start = 0;
@ -11159,6 +11163,11 @@ var spine;
skeleton.updateWorldTransform(); skeleton.updateWorldTransform();
this.updateGeometry(); this.updateGeometry();
}; };
SkeletonMesh.prototype.dispose = function () {
for (var i = 0; i < this.batches.length; i++) {
this.batches[i].dispose();
}
};
SkeletonMesh.prototype.clearBatches = function () { SkeletonMesh.prototype.clearBatches = function () {
for (var i = 0; i < this.batches.length; i++) { for (var i = 0; i < this.batches.length; i++) {
this.batches[i].clear(); 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 indices;
private indicesLength; private indicesLength;
constructor(maxVertices?: number); constructor(maxVertices?: number);
dispose(): void;
clear(): void; clear(): void;
begin(): void; begin(): void;
canBatch(verticesLength: number, indicesLength: number): boolean; canBatch(verticesLength: number, indicesLength: number): boolean;
@ -1370,6 +1371,7 @@ declare module spine.threejs {
private tempColor; private tempColor;
constructor(skeletonData: SkeletonData); constructor(skeletonData: SkeletonData);
update(deltaTime: number): void; update(deltaTime: number): void;
dispose(): void;
private clearBatches(); private clearBatches();
private nextBatch(); private nextBatch();
private updateGeometry(); private updateGeometry();

View File

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

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>spine-threejs</title> <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> <script src="../../build/spine-threejs.js"></script>
</head> </head>
<style> <style>

View File

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

View File

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