mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
* Expand static three.js workflows and host integration * Preserve JavaScript class state in static three.js workflows * Preserve inferred JavaScript behavior across static workflows * Preserve inferred callables and native compatibility boundaries * Retain annotated JavaScript factory exports and bootstrap-safe call spreads * Preserve Buffer and child callback identities in static packages * Clarify JavaScript symbol spread support
25 lines
1.2 KiB
JavaScript
25 lines
1.2 KiB
JavaScript
import { DataTexture } from 'three';
|
|
import { Data3DTexture } from 'three';
|
|
import { DataArrayTexture } from 'three';
|
|
import { DepthTexture } from 'three';
|
|
import { Texture } from 'three';
|
|
import { Vector2 } from 'three';
|
|
import { RGBAFormat } from 'three';
|
|
import { UnsignedByteType } from 'three';
|
|
;
|
|
const data = new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255]);
|
|
const texture = new DataTexture(data, 2, 1, RGBAFormat, UnsignedByteType);
|
|
texture.needsUpdate = true;
|
|
console.log('data', texture.image.width, texture.image.data[4], texture.version, texture.source.version);
|
|
texture.offset.set(0.25, 0.5);
|
|
texture.repeat.set(2, 2);
|
|
texture.updateMatrix();
|
|
const uv = new Vector2(0.2, 0.2);
|
|
texture.transformUv(uv);
|
|
console.log('uv', uv.x.toFixed(3), uv.y.toFixed(3));
|
|
const clone = texture.clone();
|
|
console.log('clone', clone !== texture, clone.source === texture.source, clone.image.data === texture.image.data);
|
|
console.log('3d', new Data3DTexture(new Uint8Array(8), 2, 2, 2).image.depth, new DataArrayTexture(new Uint8Array(8), 2, 2, 2).image.depth, new DepthTexture(2, 3).image.height);
|
|
const depth = new DepthTexture();
|
|
console.log('default depth', depth.image.width, depth.image.height, depth.image.depth);
|