three APIs
- Vector3
- Color
- Object3D
- Vector2
- BufferGeometry
- Scene
- Mesh
- MeshBasicMaterial
- Material
- Camera
- Raycaster
- DoubleSide
- WebGLRenderer
- Euler
- Quaternion
- BufferAttribute
- Group
- MeshStandardMaterial
- MeshPhongMaterial
- MathUtils
- Matrix4
- Texture
- PerspectiveCamera
- TextureLoader
- RGBAFormat
- MeshPhysicalMaterial
- MeshToonMaterial
- MeshLambertMaterial
- MeshMatcapMaterial
- DirectionalLight
- AudioAnalyser
- Plane
- ShaderMaterial
- ShaderLib
- UniformsUtils
- OrthographicCamera
- AudioListener
- LinearFilter
- UnsignedByteType
- ExtrudeGeometry
- FontLoader
- NearestFilter
- WebGLCubeRenderTarget
- Intersection
- MeshNormalMaterial
- MeshDepthMaterial
- IUniform
- EventDispatcher
- MOUSE
- TOUCH
- Line
- LineBasicMaterial
- NormalBlending
- Vector4
- TrianglesDrawMode
- Uniform
- Renderer
- NoBlending
- AdditiveBlending
- MultiplyBlending
- SubtractiveBlending
- Audio
- AudioLoader
- FileLoader
- Cache
- DynamicDrawUsage
- FogExp2
- PMREMGenerator
- Font
- ShapeBufferGeometry
- Box3
- PositionalAudio
- sRGBEncoding
- BoxBufferGeometry
- XRSession
- InterleavedBufferAttribute
- Clock
- Float32BufferAttribute
- Frustum
- Uint32BufferAttribute
- InstancedMesh
- BoxGeometry
- CircleGeometry
- ConeGeometry
- CylinderGeometry
- DodecahedronGeometry
- ExtrudeGeometryOptions
- Shape
- IcosahedronGeometry
- LatheGeometry
- OctahedronGeometry
- PlaneGeometry
- PolyhedronGeometry
- RingGeometry
- ShapeGeometry
- SphereGeometry
- TetrahedronGeometry
- TorusGeometry
- TorusKnotGeometry
- CatmullRomCurve3
- Curve
- TubeGeometry
- ShaderChunk
Other Related APIs
three#Cache TypeScript Examples
The following examples show how to use
three#Cache.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useArt.ts From metaplex with Apache License 2.0 | 5 votes |
useCachedImage = (uri: string, cacheMesh?: boolean) => {
const [cachedBlob, setCachedBlob] = useState<string | undefined>(undefined);
const [isLoading, setIsLoading] = useState<boolean>(true);
useEffect(() => {
if (!uri) {
return;
}
const result = cachedImages.get(uri);
if (result) {
setCachedBlob(result);
return;
}
(async () => {
let response: Response;
let blob: Blob;
try {
response = await fetch(uri, { cache: 'force-cache' });
blob = await response.blob();
if (blob.size === 0) {
throw new Error('No content');
}
} catch {
try {
response = await fetch(uri, { cache: 'reload' });
blob = await response.blob();
} catch {
// If external URL, just use the uri
if (uri?.startsWith('http')) {
setCachedBlob(uri);
}
setIsLoading(false);
return;
}
}
if (blob.size === 0) {
setIsLoading(false);
return;
}
if (cacheMesh) {
// extra caching for meshviewer
Cache.enabled = true;
Cache.add(uri, await blob.arrayBuffer());
}
const blobURI = URL.createObjectURL(blob);
cachedImages.set(uri, blobURI);
setCachedBlob(blobURI);
setIsLoading(false);
})();
}, [uri, setCachedBlob, setIsLoading]);
return { cachedBlob, isLoading };
}