Skip to content

Commit

Permalink
Remove Android test target
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Joel authored and cdata committed Aug 12, 2019
1 parent cb38366 commit ce23cb6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
11 changes: 7 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,13 @@ <h3 class="grouping-title">Properties</h3>
<li>
<div>ModelViewer.modelCacheSize</div>
<p>This static, writable property sets &lt;model-viewer&gt;'s internal
cache size for GLTF models. Note that any number of models may be cached
at any given time. This number just sets the maximum number of models
that can be cached even if they are not being used by a &lt;model-viewer&gt;
element in the document.</p>
glTF model cache size, controlling number of individual models that should
be cached. Note that any number of models may be cached at a given time.
This number just sets the maximum number of models that can be cached even
if they are not being used by a &lt;model-viewer&gt; element in the document.
Note also that the cache size is measured in number of glTF models, not bytes!
This is important to keep in mind, since any two models may have wildly
different byte sizes.</p>
</li>
</ul>

Expand Down
48 changes: 23 additions & 25 deletions src/three-components/CachingGLTFLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,33 @@ export class CachingGLTFLoader {

this[$evictionPolicy].retain(url);

Object.defineProperty(model, $releaseFromCache, {
value: (() => {
let released = false;
return () => {
if (released) {
(model as CacheRetainedScene)[$releaseFromCache] = (() => {
let released = false;
return () => {
if (released) {
return;
}

// We manually dispose cloned materials because Three.js keeps
// an internal count of materials using the same program, so it's
// safe to dispose of them incrementally. Geometry clones are not
// accounted for, so they cannot be disposed of incrementally.
model.traverse((object3D) => {
if (!(object3D as Mesh).isMesh) {
return;
}

// We manually dispose cloned materials because Three.js keeps
// an internal count of materials using the same program, so it's
// safe to dispose of them incrementally. Geometry clones are not
// accounted for, so they cannot be disposed of incrementally.
model.traverse((object3D) => {
if (!(object3D as Mesh).isMesh) {
return;
}
const mesh = object3D as Mesh;
const materials = Array.isArray(mesh.material) ? mesh.material :
[mesh.material];
materials.forEach(material => {
material.dispose();
});
const mesh = object3D as Mesh;
const materials =
Array.isArray(mesh.material) ? mesh.material : [mesh.material];
materials.forEach(material => {
material.dispose();
});
});

this[$evictionPolicy].release(url);
released = true;
};
})()
});
this[$evictionPolicy].release(url);
released = true;
};
})();
}

return model as CacheRetainedScene | null;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export {

export type Constructor<T = object> = {
new (...args: any[]): T,
prototype: T,
prototype: T
};

export const deserializeUrl = (url: string|null): string|null =>
Expand Down

0 comments on commit ce23cb6

Please sign in to comment.