import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { $ as Camera, $i as OrthographicCamera, $n as InstancedMesh, As as UniformsUtils, Bo as Sphere, Br as LinearMipmapNearestFilter, Bs as Vector2, C as AnimationMixer, Da as RGBAFormat, Dn as Frustum, Dr as Line, Ea as RGBADepthPacking, Er as LightProbe, Fa as RGBA_ASTC_4x4_Format, Fr as LinearFilter, G as Box3Helper, Ga as RGBA_PVRTC_2BPPV1_Format, Gi as OctahedronGeometry, Gn as ImageBitmapLoader, Go as SpotLight, Gr as LoaderUtils, H as BooleanKeyframeTrack, Hi as Object3D, Ho as Spherical, Hs as Vector4, Ht as DataTexture, Io as Skeleton, J as BufferAttribute, Ja as RGBA_S3TC_DXT3_Format, Jn as IncrementStencilOp, Jo as SpriteMaterial, K as BoxGeometry, Ka as RGBA_PVRTC_4BPPV1_Format, Kr as LoadingManager, Lo as SkeletonHelper, No as ShapePath, Nr as LineLoop, Ns as UnsignedInt248Type, Oo as Scene, Or as Line3, Os as Uniform, Po as ShapeUtils, Pr as LineSegments, Pt as Curve, Qn as InstancedInterleavedBuffer, Qs as WireframeGeometry, Qt as DirectionalLight, Rn as GridHelper, Ro as SkinnedMesh, Rs as UnsignedShortType, Rt as CylinderGeometry, Sn as FloatType, Ti as NearestMipmapNearestFilter, Ts as Uint32BufferAttribute, U as Box2, Ua as RGBA_BPTC_Format, Uo as SphericalHarmonics3, Us as VectorKeyframeTrack, Ut as DataTextureLoader, V as Bone, Vi as NumberKeyframeTrack, Vn as HalfFloatType, Vo as SphereGeometry, Vs as Vector3, W as Box3, Wa as RGBA_ETC2_EAC_Format, Wn as IcosahedronGeometry, Wr as Loader, Wt as DataUtils, X as BufferGeometryLoader, Xn as InstancedBufferAttribute, Xr as MOUSE, Xt as DepthTexture, Y as BufferGeometry, Ya as RGBA_S3TC_DXT5_Format, Ys as WebGLRenderTarget, Yt as DepthStencilFormat, Zn as InstancedBufferGeometry, Zr as Material, _i as MirroredRepeatWrapping, _r as LatheGeometry, a as WebGLCubeRenderTarget, aa as PlaneGeometry, ai as Mesh, ao as RGB_S3TC_DXT1_Format, ar as InterleavedBufferAttribute, cr as InterpolateDiscrete, cs as TOUCH, ct as Color, di as MeshNormalMaterial, do as Raycaster, ds as Texture, ei as MathUtils, fi as MeshPhongMaterial, fo as RectAreaLight, fs as TextureLoader, gn as EventDispatcher$1, gs as TorusGeometry, gt as ConeGeometry, hi as MeshToonMaterial, hn as Euler, ht as CompressedTextureLoader, i as UniformsLib, ia as Plane, io as RGB_PVRTC_4BPPV1_Format, ir as InterleavedBuffer, jo as Shape, js as UnsignedByteType, ko as ShaderMaterial, kr as LineBasicMaterial, la as Points, li as MeshLambertMaterial, ln as EllipseCurve, lo as RawShaderMaterial, lr as InterpolateLinear, lt as ColorKeyframeTrack, ma as PropertyBinding, mi as MeshStandardMaterial, mt as CompressedTexture, n as ShaderChunk, na as Path, ni as Matrix3, no as RGB_ETC2_Format, o as WebGLRenderer, oi as MeshBasicMaterial, on as DynamicDrawUsage, or as Interpolant, ot as ClampToEdgeWrapping, pi as MeshPhysicalMaterial, po as RedFormat, qo as Sprite, qt as DefaultLoadingManager, r as ShaderLib, ra as PerspectiveCamera, ri as Matrix4, ro as RGB_PVRTC_2BPPV1_Format, sa as PointLight, si as MeshDepthMaterial, so as RGFormat, st as Clock, to as RGB_ETC1_Format, ts as StereoCamera, tt as CanvasTexture, ua as PointsMaterial, uo as Ray, va as Quaternion, vn as ExtrudeGeometry, vo as RepeatWrapping, vs as Triangle$1, wi as NearestMipmapLinearFilter, ws as Uint16BufferAttribute, wt as CubeTexture, x as AnimationClip, xi as NearestFilter, xn as Float32BufferAttribute, y as AmbientLight, ya as QuaternionKeyframeTrack, yn as FileLoader, za as RGBA_ASTC_6x6_Format, zn as Group, zr as LinearMipmapLinearFilter } from "./three.module-DxhMWCDR.js";
//#region node_modules/three-stdlib/loaders/MD2Loader.js
var _normalData = [
[
-.525731,
0,
.850651
],
[
-.442863,
.238856,
.864188
],
[
-.295242,
0,
.955423
],
[
-.309017,
.5,
.809017
],
[
-.16246,
.262866,
.951056
],
[
0,
0,
1
],
[
0,
.850651,
.525731
],
[
-.147621,
.716567,
.681718
],
[
.147621,
.716567,
.681718
],
[
0,
.525731,
.850651
],
[
.309017,
.5,
.809017
],
[
.525731,
0,
.850651
],
[
.295242,
0,
.955423
],
[
.442863,
.238856,
.864188
],
[
.16246,
.262866,
.951056
],
[
-.681718,
.147621,
.716567
],
[
-.809017,
.309017,
.5
],
[
-.587785,
.425325,
.688191
],
[
-.850651,
.525731,
0
],
[
-.864188,
.442863,
.238856
],
[
-.716567,
.681718,
.147621
],
[
-.688191,
.587785,
.425325
],
[
-.5,
.809017,
.309017
],
[
-.238856,
.864188,
.442863
],
[
-.425325,
.688191,
.587785
],
[
-.716567,
.681718,
-.147621
],
[
-.5,
.809017,
-.309017
],
[
-.525731,
.850651,
0
],
[
0,
.850651,
-.525731
],
[
-.238856,
.864188,
-.442863
],
[
0,
.955423,
-.295242
],
[
-.262866,
.951056,
-.16246
],
[
0,
1,
0
],
[
0,
.955423,
.295242
],
[
-.262866,
.951056,
.16246
],
[
.238856,
.864188,
.442863
],
[
.262866,
.951056,
.16246
],
[
.5,
.809017,
.309017
],
[
.238856,
.864188,
-.442863
],
[
.262866,
.951056,
-.16246
],
[
.5,
.809017,
-.309017
],
[
.850651,
.525731,
0
],
[
.716567,
.681718,
.147621
],
[
.716567,
.681718,
-.147621
],
[
.525731,
.850651,
0
],
[
.425325,
.688191,
.587785
],
[
.864188,
.442863,
.238856
],
[
.688191,
.587785,
.425325
],
[
.809017,
.309017,
.5
],
[
.681718,
.147621,
.716567
],
[
.587785,
.425325,
.688191
],
[
.955423,
.295242,
0
],
[
1,
0,
0
],
[
.951056,
.16246,
.262866
],
[
.850651,
-.525731,
0
],
[
.955423,
-.295242,
0
],
[
.864188,
-.442863,
.238856
],
[
.951056,
-.16246,
.262866
],
[
.809017,
-.309017,
.5
],
[
.681718,
-.147621,
.716567
],
[
.850651,
0,
.525731
],
[
.864188,
.442863,
-.238856
],
[
.809017,
.309017,
-.5
],
[
.951056,
.16246,
-.262866
],
[
.525731,
0,
-.850651
],
[
.681718,
.147621,
-.716567
],
[
.681718,
-.147621,
-.716567
],
[
.850651,
0,
-.525731
],
[
.809017,
-.309017,
-.5
],
[
.864188,
-.442863,
-.238856
],
[
.951056,
-.16246,
-.262866
],
[
.147621,
.716567,
-.681718
],
[
.309017,
.5,
-.809017
],
[
.425325,
.688191,
-.587785
],
[
.442863,
.238856,
-.864188
],
[
.587785,
.425325,
-.688191
],
[
.688191,
.587785,
-.425325
],
[
-.147621,
.716567,
-.681718
],
[
-.309017,
.5,
-.809017
],
[
0,
.525731,
-.850651
],
[
-.525731,
0,
-.850651
],
[
-.442863,
.238856,
-.864188
],
[
-.295242,
0,
-.955423
],
[
-.16246,
.262866,
-.951056
],
[
0,
0,
-1
],
[
.295242,
0,
-.955423
],
[
.16246,
.262866,
-.951056
],
[
-.442863,
-.238856,
-.864188
],
[
-.309017,
-.5,
-.809017
],
[
-.16246,
-.262866,
-.951056
],
[
0,
-.850651,
-.525731
],
[
-.147621,
-.716567,
-.681718
],
[
.147621,
-.716567,
-.681718
],
[
0,
-.525731,
-.850651
],
[
.309017,
-.5,
-.809017
],
[
.442863,
-.238856,
-.864188
],
[
.16246,
-.262866,
-.951056
],
[
.238856,
-.864188,
-.442863
],
[
.5,
-.809017,
-.309017
],
[
.425325,
-.688191,
-.587785
],
[
.716567,
-.681718,
-.147621
],
[
.688191,
-.587785,
-.425325
],
[
.587785,
-.425325,
-.688191
],
[
0,
-.955423,
-.295242
],
[
0,
-1,
0
],
[
.262866,
-.951056,
-.16246
],
[
0,
-.850651,
.525731
],
[
0,
-.955423,
.295242
],
[
.238856,
-.864188,
.442863
],
[
.262866,
-.951056,
.16246
],
[
.5,
-.809017,
.309017
],
[
.716567,
-.681718,
.147621
],
[
.525731,
-.850651,
0
],
[
-.238856,
-.864188,
-.442863
],
[
-.5,
-.809017,
-.309017
],
[
-.262866,
-.951056,
-.16246
],
[
-.850651,
-.525731,
0
],
[
-.716567,
-.681718,
-.147621
],
[
-.716567,
-.681718,
.147621
],
[
-.525731,
-.850651,
0
],
[
-.5,
-.809017,
.309017
],
[
-.238856,
-.864188,
.442863
],
[
-.262866,
-.951056,
.16246
],
[
-.864188,
-.442863,
.238856
],
[
-.809017,
-.309017,
.5
],
[
-.688191,
-.587785,
.425325
],
[
-.681718,
-.147621,
.716567
],
[
-.442863,
-.238856,
.864188
],
[
-.587785,
-.425325,
.688191
],
[
-.309017,
-.5,
.809017
],
[
-.147621,
-.716567,
.681718
],
[
-.425325,
-.688191,
.587785
],
[
-.16246,
-.262866,
.951056
],
[
.442863,
-.238856,
.864188
],
[
.16246,
-.262866,
.951056
],
[
.309017,
-.5,
.809017
],
[
.147621,
-.716567,
.681718
],
[
0,
-.525731,
.850651
],
[
.425325,
-.688191,
.587785
],
[
.587785,
-.425325,
.688191
],
[
.688191,
-.587785,
.425325
],
[
-.955423,
.295242,
0
],
[
-.951056,
.16246,
.262866
],
[
-1,
0,
0
],
[
-.850651,
0,
.525731
],
[
-.955423,
-.295242,
0
],
[
-.951056,
-.16246,
.262866
],
[
-.864188,
.442863,
-.238856
],
[
-.951056,
.16246,
-.262866
],
[
-.809017,
.309017,
-.5
],
[
-.864188,
-.442863,
-.238856
],
[
-.951056,
-.16246,
-.262866
],
[
-.809017,
-.309017,
-.5
],
[
-.681718,
.147621,
-.716567
],
[
-.681718,
-.147621,
-.716567
],
[
-.850651,
0,
-.525731
],
[
-.688191,
.587785,
-.425325
],
[
-.587785,
.425325,
-.688191
],
[
-.425325,
.688191,
-.587785
],
[
-.425325,
-.688191,
-.587785
],
[
-.587785,
-.425325,
-.688191
],
[
-.688191,
-.587785,
-.425325
]
];
var MD2Loader = class extends Loader {
constructor(manager) {
super(manager);
}
load(url, onLoad, onProgress, onError) {
const scope = this;
const loader = new FileLoader(scope.manager);
loader.setPath(scope.path);
loader.setResponseType("arraybuffer");
loader.setRequestHeader(scope.requestHeader);
loader.setWithCredentials(scope.withCredentials);
loader.load(url, function(buffer) {
try {
onLoad(scope.parse(buffer));
} catch (e) {
if (onError) onError(e);
else console.error(e);
scope.manager.itemError(url);
}
}, onProgress, onError);
}
parse(buffer) {
const data = new DataView(buffer);
const header = {};
const headerNames = [
"ident",
"version",
"skinwidth",
"skinheight",
"framesize",
"num_skins",
"num_vertices",
"num_st",
"num_tris",
"num_glcmds",
"num_frames",
"offset_skins",
"offset_st",
"offset_tris",
"offset_frames",
"offset_glcmds",
"offset_end"
];
for (let i = 0; i < headerNames.length; i++) header[headerNames[i]] = data.getInt32(i * 4, true);
if (header.ident !== 844121161 || header.version !== 8) {
console.error("Not a valid MD2 file");
return;
}
if (header.offset_end !== data.byteLength) {
console.error("Corrupted MD2 file");
return;
}
const geometry = new BufferGeometry();
const uvsTemp = [];
let offset = header.offset_st;
for (let i = 0, l = header.num_st; i < l; i++) {
const u = data.getInt16(offset + 0, true);
const v = data.getInt16(offset + 2, true);
uvsTemp.push(u / header.skinwidth, 1 - v / header.skinheight);
offset += 4;
}
offset = header.offset_tris;
const vertexIndices = [];
const uvIndices = [];
for (let i = 0, l = header.num_tris; i < l; i++) {
vertexIndices.push(data.getUint16(offset + 0, true), data.getUint16(offset + 2, true), data.getUint16(offset + 4, true));
uvIndices.push(data.getUint16(offset + 6, true), data.getUint16(offset + 8, true), data.getUint16(offset + 10, true));
offset += 12;
}
const translation = new Vector3();
const scale = new Vector3();
const string = [];
const frames = [];
offset = header.offset_frames;
for (let i = 0, l = header.num_frames; i < l; i++) {
scale.set(data.getFloat32(offset + 0, true), data.getFloat32(offset + 4, true), data.getFloat32(offset + 8, true));
translation.set(data.getFloat32(offset + 12, true), data.getFloat32(offset + 16, true), data.getFloat32(offset + 20, true));
offset += 24;
for (let j = 0; j < 16; j++) {
const character = data.getUint8(offset + j, true);
if (character === 0) break;
string[j] = character;
}
const frame = {
name: String.fromCharCode.apply(null, string),
vertices: [],
normals: []
};
offset += 16;
for (let j = 0; j < header.num_vertices; j++) {
let x = data.getUint8(offset++, true);
let y = data.getUint8(offset++, true);
let z = data.getUint8(offset++, true);
const n = _normalData[data.getUint8(offset++, true)];
x = x * scale.x + translation.x;
y = y * scale.y + translation.y;
z = z * scale.z + translation.z;
frame.vertices.push(x, z, y);
frame.normals.push(n[0], n[2], n[1]);
}
frames.push(frame);
}
const positions = [];
const normals = [];
const uvs = [];
const verticesTemp = frames[0].vertices;
const normalsTemp = frames[0].normals;
for (let i = 0, l = vertexIndices.length; i < l; i++) {
let stride = vertexIndices[i] * 3;
const x = verticesTemp[stride];
const y = verticesTemp[stride + 1];
const z = verticesTemp[stride + 2];
positions.push(x, y, z);
const nx = normalsTemp[stride];
const ny = normalsTemp[stride + 1];
const nz = normalsTemp[stride + 2];
normals.push(nx, ny, nz);
stride = uvIndices[i] * 2;
const u = uvsTemp[stride];
const v = uvsTemp[stride + 1];
uvs.push(u, v);
}
geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
const morphPositions = [];
const morphNormals = [];
for (let i = 0, l = frames.length; i < l; i++) {
const frame = frames[i];
const attributeName = frame.name;
if (frame.vertices.length > 0) {
const positions2 = [];
for (let j = 0, jl = vertexIndices.length; j < jl; j++) {
const stride = vertexIndices[j] * 3;
const x = frame.vertices[stride];
const y = frame.vertices[stride + 1];
const z = frame.vertices[stride + 2];
positions2.push(x, y, z);
}
const positionAttribute = new Float32BufferAttribute(positions2, 3);
positionAttribute.name = attributeName;
morphPositions.push(positionAttribute);
}
if (frame.normals.length > 0) {
const normals2 = [];
for (let j = 0, jl = vertexIndices.length; j < jl; j++) {
const stride = vertexIndices[j] * 3;
const nx = frame.normals[stride];
const ny = frame.normals[stride + 1];
const nz = frame.normals[stride + 2];
normals2.push(nx, ny, nz);
}
const normalAttribute = new Float32BufferAttribute(normals2, 3);
normalAttribute.name = attributeName;
morphNormals.push(normalAttribute);
}
}
geometry.morphAttributes.position = morphPositions;
geometry.morphAttributes.normal = morphNormals;
geometry.morphTargetsRelative = false;
geometry.animations = AnimationClip.CreateClipsFromMorphTargetSequences(frames, 10);
return geometry;
}
};
//#endregion
//#region node_modules/three-stdlib/misc/MorphBlendMesh.js
var MorphBlendMesh = class extends Mesh {
constructor(geometry, material) {
super(geometry, material);
this.animationsMap = {};
this.animationsList = [];
const numFrames = Object.keys(this.morphTargetDictionary).length;
const name = "__default";
const startFrame = 0;
const endFrame = numFrames - 1;
const fps = numFrames / 1;
this.createAnimation(name, startFrame, endFrame, fps);
this.setAnimationWeight(name, 1);
}
createAnimation(name, start, end, fps) {
const animation = {
start,
end,
length: end - start + 1,
fps,
duration: (end - start) / fps,
lastFrame: 0,
currentFrame: 0,
active: false,
time: 0,
direction: 1,
weight: 1,
directionBackwards: false,
mirroredLoop: false
};
this.animationsMap[name] = animation;
this.animationsList.push(animation);
}
autoCreateAnimations(fps) {
const pattern = /([a-z]+)_?(\d+)/i;
let firstAnimation;
const frameRanges = {};
let i = 0;
for (const key in this.morphTargetDictionary) {
const chunks = key.match(pattern);
if (chunks && chunks.length > 1) {
const name = chunks[1];
if (!frameRanges[name]) frameRanges[name] = {
start: Infinity,
end: -Infinity
};
const range = frameRanges[name];
if (i < range.start) range.start = i;
if (i > range.end) range.end = i;
if (!firstAnimation) firstAnimation = name;
}
i++;
}
for (const name in frameRanges) {
const range = frameRanges[name];
this.createAnimation(name, range.start, range.end, fps);
}
this.firstAnimation = firstAnimation;
}
setAnimationDirectionForward(name) {
const animation = this.animationsMap[name];
if (animation) {
animation.direction = 1;
animation.directionBackwards = false;
}
}
setAnimationDirectionBackward(name) {
const animation = this.animationsMap[name];
if (animation) {
animation.direction = -1;
animation.directionBackwards = true;
}
}
setAnimationFPS(name, fps) {
const animation = this.animationsMap[name];
if (animation) {
animation.fps = fps;
animation.duration = (animation.end - animation.start) / animation.fps;
}
}
setAnimationDuration(name, duration) {
const animation = this.animationsMap[name];
if (animation) {
animation.duration = duration;
animation.fps = (animation.end - animation.start) / animation.duration;
}
}
setAnimationWeight(name, weight) {
const animation = this.animationsMap[name];
if (animation) animation.weight = weight;
}
setAnimationTime(name, time) {
const animation = this.animationsMap[name];
if (animation) animation.time = time;
}
getAnimationTime(name) {
let time = 0;
const animation = this.animationsMap[name];
if (animation) time = animation.time;
return time;
}
getAnimationDuration(name) {
let duration = -1;
const animation = this.animationsMap[name];
if (animation) duration = animation.duration;
return duration;
}
playAnimation(name) {
const animation = this.animationsMap[name];
if (animation) {
animation.time = 0;
animation.active = true;
} else console.warn("THREE.MorphBlendMesh: animation[" + name + "] undefined in .playAnimation()");
}
stopAnimation(name) {
const animation = this.animationsMap[name];
if (animation) animation.active = false;
}
update(delta) {
for (let i = 0, il = this.animationsList.length; i < il; i++) {
const animation = this.animationsList[i];
if (!animation.active) continue;
const frameTime = animation.duration / animation.length;
animation.time += animation.direction * delta;
if (animation.mirroredLoop) {
if (animation.time > animation.duration || animation.time < 0) {
animation.direction *= -1;
if (animation.time > animation.duration) {
animation.time = animation.duration;
animation.directionBackwards = true;
}
if (animation.time < 0) {
animation.time = 0;
animation.directionBackwards = false;
}
}
} else {
animation.time = animation.time % animation.duration;
if (animation.time < 0) animation.time += animation.duration;
}
const keyframe = animation.start + MathUtils.clamp(Math.floor(animation.time / frameTime), 0, animation.length - 1);
const weight = animation.weight;
if (keyframe !== animation.currentFrame) {
this.morphTargetInfluences[animation.lastFrame] = 0;
this.morphTargetInfluences[animation.currentFrame] = 1 * weight;
this.morphTargetInfluences[keyframe] = 0;
animation.lastFrame = animation.currentFrame;
animation.currentFrame = keyframe;
}
let mix = animation.time % frameTime / frameTime;
if (animation.directionBackwards) mix = 1 - mix;
if (animation.currentFrame !== animation.lastFrame) {
this.morphTargetInfluences[animation.currentFrame] = mix * weight;
this.morphTargetInfluences[animation.lastFrame] = (1 - mix) * weight;
} else this.morphTargetInfluences[animation.currentFrame] = weight;
}
}
};
//#endregion
//#region node_modules/three-stdlib/misc/MD2CharacterComplex.js
var MD2CharacterComplex = class {
constructor() {
this.scale = 1;
this.animationFPS = 6;
this.transitionFrames = 15;
this.maxSpeed = 275;
this.maxReverseSpeed = -275;
this.frontAcceleration = 600;
this.backAcceleration = 600;
this.frontDecceleration = 600;
this.angularSpeed = 2.5;
this.root = new Object3D();
this.meshBody = null;
this.meshWeapon = null;
this.controls = null;
this.skinsBody = [];
this.skinsWeapon = [];
this.weapons = [];
this.currentSkin = void 0;
this.onLoadComplete = function() {};
this.meshes = [];
this.animations = {};
this.loadCounter = 0;
this.speed = 0;
this.bodyOrientation = 0;
this.walkSpeed = this.maxSpeed;
this.crouchSpeed = this.maxSpeed * .5;
this.activeAnimation = null;
this.oldAnimation = null;
}
enableShadows(enable) {
for (let i = 0; i < this.meshes.length; i++) {
this.meshes[i].castShadow = enable;
this.meshes[i].receiveShadow = enable;
}
}
setVisible(enable) {
for (let i = 0; i < this.meshes.length; i++) {
this.meshes[i].visible = enable;
this.meshes[i].visible = enable;
}
}
shareParts(original) {
this.animations = original.animations;
this.walkSpeed = original.walkSpeed;
this.crouchSpeed = original.crouchSpeed;
this.skinsBody = original.skinsBody;
this.skinsWeapon = original.skinsWeapon;
const mesh = this._createPart(original.meshBody.geometry, this.skinsBody[0]);
mesh.scale.set(this.scale, this.scale, this.scale);
this.root.position.y = original.root.position.y;
this.root.add(mesh);
this.meshBody = mesh;
this.meshes.push(mesh);
for (let i = 0; i < original.weapons.length; i++) {
const meshWeapon = this._createPart(original.weapons[i].geometry, this.skinsWeapon[i]);
meshWeapon.scale.set(this.scale, this.scale, this.scale);
meshWeapon.visible = false;
meshWeapon.name = original.weapons[i].name;
this.root.add(meshWeapon);
this.weapons[i] = meshWeapon;
this.meshWeapon = meshWeapon;
this.meshes.push(meshWeapon);
}
}
loadParts(config) {
const scope = this;
function loadTextures(baseUrl, textureUrls) {
const textureLoader = new TextureLoader();
const textures = [];
for (let i = 0; i < textureUrls.length; i++) {
textures[i] = textureLoader.load(baseUrl + textureUrls[i], checkLoadingComplete);
textures[i].mapping = 300;
textures[i].name = textureUrls[i];
if ("colorSpace" in textures[i]) textures[i].colorSpace = "srgb";
else textures[i].encoding = 3001;
}
return textures;
}
function checkLoadingComplete() {
scope.loadCounter -= 1;
if (scope.loadCounter === 0) scope.onLoadComplete();
}
this.animations = config.animations;
this.walkSpeed = config.walkSpeed;
this.crouchSpeed = config.crouchSpeed;
this.loadCounter = config.weapons.length * 2 + config.skins.length + 1;
const weaponsTextures = [];
for (let i = 0; i < config.weapons.length; i++) weaponsTextures[i] = config.weapons[i][1];
this.skinsBody = loadTextures(config.baseUrl + "skins/", config.skins);
this.skinsWeapon = loadTextures(config.baseUrl + "skins/", weaponsTextures);
const loader = new MD2Loader();
loader.load(config.baseUrl + config.body, function(geo) {
const boundingBox = new Box3();
boundingBox.setFromBufferAttribute(geo.attributes.position);
scope.root.position.y = -scope.scale * boundingBox.min.y;
const mesh = scope._createPart(geo, scope.skinsBody[0]);
mesh.scale.set(scope.scale, scope.scale, scope.scale);
scope.root.add(mesh);
scope.meshBody = mesh;
scope.meshes.push(mesh);
checkLoadingComplete();
});
const generateCallback = function(index, name) {
return function(geo) {
const mesh = scope._createPart(geo, scope.skinsWeapon[index]);
mesh.scale.set(scope.scale, scope.scale, scope.scale);
mesh.visible = false;
mesh.name = name;
scope.root.add(mesh);
scope.weapons[index] = mesh;
scope.meshWeapon = mesh;
scope.meshes.push(mesh);
checkLoadingComplete();
};
};
for (let i = 0; i < config.weapons.length; i++) loader.load(config.baseUrl + config.weapons[i][0], generateCallback(i, config.weapons[i][0]));
}
setPlaybackRate(rate) {
if (this.meshBody) this.meshBody.duration = this.meshBody.baseDuration / rate;
if (this.meshWeapon) this.meshWeapon.duration = this.meshWeapon.baseDuration / rate;
}
setWireframe(wireframeEnabled) {
if (wireframeEnabled) {
if (this.meshBody) this.meshBody.material = this.meshBody.materialWireframe;
if (this.meshWeapon) this.meshWeapon.material = this.meshWeapon.materialWireframe;
} else {
if (this.meshBody) this.meshBody.material = this.meshBody.materialTexture;
if (this.meshWeapon) this.meshWeapon.material = this.meshWeapon.materialTexture;
}
}
setSkin(index) {
if (this.meshBody && this.meshBody.material.wireframe === false) {
this.meshBody.material.map = this.skinsBody[index];
this.currentSkin = index;
}
}
setWeapon(index) {
for (let i = 0; i < this.weapons.length; i++) this.weapons[i].visible = false;
const activeWeapon = this.weapons[index];
if (activeWeapon) {
activeWeapon.visible = true;
this.meshWeapon = activeWeapon;
if (this.activeAnimation) {
activeWeapon.playAnimation(this.activeAnimation);
this.meshWeapon.setAnimationTime(this.activeAnimation, this.meshBody.getAnimationTime(this.activeAnimation));
}
}
}
setAnimation(animationName) {
if (animationName === this.activeAnimation || !animationName) return;
if (this.meshBody) {
this.meshBody.setAnimationWeight(animationName, 0);
this.meshBody.playAnimation(animationName);
this.oldAnimation = this.activeAnimation;
this.activeAnimation = animationName;
this.blendCounter = this.transitionFrames;
}
if (this.meshWeapon) {
this.meshWeapon.setAnimationWeight(animationName, 0);
this.meshWeapon.playAnimation(animationName);
}
}
update(delta) {
if (this.controls) this.updateMovementModel(delta);
if (this.animations) {
this.updateBehaviors();
this.updateAnimations(delta);
}
}
updateAnimations(delta) {
let mix = 1;
if (this.blendCounter > 0) {
mix = (this.transitionFrames - this.blendCounter) / this.transitionFrames;
this.blendCounter -= 1;
}
if (this.meshBody) {
this.meshBody.update(delta);
this.meshBody.setAnimationWeight(this.activeAnimation, mix);
this.meshBody.setAnimationWeight(this.oldAnimation, 1 - mix);
}
if (this.meshWeapon) {
this.meshWeapon.update(delta);
this.meshWeapon.setAnimationWeight(this.activeAnimation, mix);
this.meshWeapon.setAnimationWeight(this.oldAnimation, 1 - mix);
}
}
updateBehaviors() {
const controls = this.controls;
const animations = this.animations;
let moveAnimation, idleAnimation;
if (controls.crouch) {
moveAnimation = animations["crouchMove"];
idleAnimation = animations["crouchIdle"];
} else {
moveAnimation = animations["move"];
idleAnimation = animations["idle"];
}
if (controls.jump) {
moveAnimation = animations["jump"];
idleAnimation = animations["jump"];
}
if (controls.attack) if (controls.crouch) {
moveAnimation = animations["crouchAttack"];
idleAnimation = animations["crouchAttack"];
} else {
moveAnimation = animations["attack"];
idleAnimation = animations["attack"];
}
if (controls.moveForward || controls.moveBackward || controls.moveLeft || controls.moveRight) {
if (this.activeAnimation !== moveAnimation) this.setAnimation(moveAnimation);
}
if (Math.abs(this.speed) < .2 * this.maxSpeed && !(controls.moveLeft || controls.moveRight || controls.moveForward || controls.moveBackward)) {
if (this.activeAnimation !== idleAnimation) this.setAnimation(idleAnimation);
}
if (controls.moveForward) {
if (this.meshBody) {
this.meshBody.setAnimationDirectionForward(this.activeAnimation);
this.meshBody.setAnimationDirectionForward(this.oldAnimation);
}
if (this.meshWeapon) {
this.meshWeapon.setAnimationDirectionForward(this.activeAnimation);
this.meshWeapon.setAnimationDirectionForward(this.oldAnimation);
}
}
if (controls.moveBackward) {
if (this.meshBody) {
this.meshBody.setAnimationDirectionBackward(this.activeAnimation);
this.meshBody.setAnimationDirectionBackward(this.oldAnimation);
}
if (this.meshWeapon) {
this.meshWeapon.setAnimationDirectionBackward(this.activeAnimation);
this.meshWeapon.setAnimationDirectionBackward(this.oldAnimation);
}
}
}
updateMovementModel(delta) {
function exponentialEaseOut(k) {
return k === 1 ? 1 : -Math.pow(2, -10 * k) + 1;
}
const controls = this.controls;
if (controls.crouch) this.maxSpeed = this.crouchSpeed;
else this.maxSpeed = this.walkSpeed;
this.maxReverseSpeed = -this.maxSpeed;
if (controls.moveForward) this.speed = MathUtils.clamp(this.speed + delta * this.frontAcceleration, this.maxReverseSpeed, this.maxSpeed);
if (controls.moveBackward) this.speed = MathUtils.clamp(this.speed - delta * this.backAcceleration, this.maxReverseSpeed, this.maxSpeed);
const dir = 1;
if (controls.moveLeft) {
this.bodyOrientation += delta * this.angularSpeed;
this.speed = MathUtils.clamp(this.speed + dir * delta * this.frontAcceleration, this.maxReverseSpeed, this.maxSpeed);
}
if (controls.moveRight) {
this.bodyOrientation -= delta * this.angularSpeed;
this.speed = MathUtils.clamp(this.speed + dir * delta * this.frontAcceleration, this.maxReverseSpeed, this.maxSpeed);
}
if (!(controls.moveForward || controls.moveBackward)) if (this.speed > 0) {
const k = exponentialEaseOut(this.speed / this.maxSpeed);
this.speed = MathUtils.clamp(this.speed - k * delta * this.frontDecceleration, 0, this.maxSpeed);
} else {
const k = exponentialEaseOut(this.speed / this.maxReverseSpeed);
this.speed = MathUtils.clamp(this.speed + k * delta * this.backAcceleration, this.maxReverseSpeed, 0);
}
const forwardDelta = this.speed * delta;
this.root.position.x += Math.sin(this.bodyOrientation) * forwardDelta;
this.root.position.z += Math.cos(this.bodyOrientation) * forwardDelta;
this.root.rotation.y = this.bodyOrientation;
}
_createPart(geometry, skinMap) {
const materialWireframe = new MeshLambertMaterial({
color: 16755200,
wireframe: true,
morphTargets: true,
morphNormals: true
});
const materialTexture = new MeshLambertMaterial({
color: 16777215,
wireframe: false,
map: skinMap,
morphTargets: true,
morphNormals: true
});
const mesh = new MorphBlendMesh(geometry, materialTexture);
mesh.rotation.y = -Math.PI / 2;
mesh.materialTexture = materialTexture;
mesh.materialWireframe = materialWireframe;
mesh.autoCreateAnimations(this.animationFPS);
return mesh;
}
};
//#endregion
//#region node_modules/three-stdlib/math/ConvexHull.js
var Visible = 0;
var Deleted = 1;
var _v1$5 = /* @__PURE__ */ new Vector3();
var _line3 = /* @__PURE__ */ new Line3();
var _plane$2 = /* @__PURE__ */ new Plane();
var _closestPoint$1 = /* @__PURE__ */ new Vector3();
var _triangle = /* @__PURE__ */ new Triangle$1();
var ConvexHull = class {
constructor() {
this.tolerance = -1;
this.faces = [];
this.newFaces = [];
this.assigned = new VertexList();
this.unassigned = new VertexList();
this.vertices = [];
}
setFromPoints(points) {
if (points.length >= 4) {
this.makeEmpty();
for (let i = 0, l = points.length; i < l; i++) this.vertices.push(new VertexNode(points[i]));
this.compute();
}
return this;
}
setFromObject(object) {
const points = [];
object.updateMatrixWorld(true);
object.traverse(function(node) {
const geometry = node.geometry;
if (geometry !== void 0) {
const attribute = geometry.attributes.position;
if (attribute !== void 0) for (let i = 0, l = attribute.count; i < l; i++) {
const point = new Vector3();
point.fromBufferAttribute(attribute, i).applyMatrix4(node.matrixWorld);
points.push(point);
}
}
});
return this.setFromPoints(points);
}
containsPoint(point) {
const faces = this.faces;
for (let i = 0, l = faces.length; i < l; i++) if (faces[i].distanceToPoint(point) > this.tolerance) return false;
return true;
}
intersectRay(ray, target) {
const faces = this.faces;
let tNear = -Infinity;
let tFar = Infinity;
for (let i = 0, l = faces.length; i < l; i++) {
const face = faces[i];
const vN = face.distanceToPoint(ray.origin);
const vD = face.normal.dot(ray.direction);
if (vN > 0 && vD >= 0) return null;
const t = vD !== 0 ? -vN / vD : 0;
if (t <= 0) continue;
if (vD > 0) tFar = Math.min(t, tFar);
else tNear = Math.max(t, tNear);
if (tNear > tFar) return null;
}
if (tNear !== -Infinity) ray.at(tNear, target);
else ray.at(tFar, target);
return target;
}
intersectsRay(ray) {
return this.intersectRay(ray, _v1$5) !== null;
}
makeEmpty() {
this.faces = [];
this.vertices = [];
return this;
}
addVertexToFace(vertex, face) {
vertex.face = face;
if (face.outside === null) this.assigned.append(vertex);
else this.assigned.insertBefore(face.outside, vertex);
face.outside = vertex;
return this;
}
removeVertexFromFace(vertex, face) {
if (vertex === face.outside) if (vertex.next !== null && vertex.next.face === face) face.outside = vertex.next;
else face.outside = null;
this.assigned.remove(vertex);
return this;
}
removeAllVerticesFromFace(face) {
if (face.outside !== null) {
const start = face.outside;
let end = face.outside;
while (end.next !== null && end.next.face === face) end = end.next;
this.assigned.removeSubList(start, end);
start.prev = end.next = null;
face.outside = null;
return start;
}
}
deleteFaceVertices(face, absorbingFace) {
const faceVertices = this.removeAllVerticesFromFace(face);
if (faceVertices !== void 0) if (absorbingFace === void 0) this.unassigned.appendChain(faceVertices);
else {
let vertex = faceVertices;
do {
const nextVertex = vertex.next;
if (absorbingFace.distanceToPoint(vertex.point) > this.tolerance) this.addVertexToFace(vertex, absorbingFace);
else this.unassigned.append(vertex);
vertex = nextVertex;
} while (vertex !== null);
}
return this;
}
resolveUnassignedPoints(newFaces) {
if (this.unassigned.isEmpty() === false) {
let vertex = this.unassigned.first();
do {
const nextVertex = vertex.next;
let maxDistance = this.tolerance;
let maxFace = null;
for (let i = 0; i < newFaces.length; i++) {
const face = newFaces[i];
if (face.mark === Visible) {
const distance = face.distanceToPoint(vertex.point);
if (distance > maxDistance) {
maxDistance = distance;
maxFace = face;
}
if (maxDistance > 1e3 * this.tolerance) break;
}
}
if (maxFace !== null) this.addVertexToFace(vertex, maxFace);
vertex = nextVertex;
} while (vertex !== null);
}
return this;
}
computeExtremes() {
const min = new Vector3();
const max = new Vector3();
const minVertices = [];
const maxVertices = [];
for (let i = 0; i < 3; i++) minVertices[i] = maxVertices[i] = this.vertices[0];
min.copy(this.vertices[0].point);
max.copy(this.vertices[0].point);
for (let i = 0, l = this.vertices.length; i < l; i++) {
const vertex = this.vertices[i];
const point = vertex.point;
for (let j = 0; j < 3; j++) if (point.getComponent(j) < min.getComponent(j)) {
min.setComponent(j, point.getComponent(j));
minVertices[j] = vertex;
}
for (let j = 0; j < 3; j++) if (point.getComponent(j) > max.getComponent(j)) {
max.setComponent(j, point.getComponent(j));
maxVertices[j] = vertex;
}
}
this.tolerance = 3 * Number.EPSILON * (Math.max(Math.abs(min.x), Math.abs(max.x)) + Math.max(Math.abs(min.y), Math.abs(max.y)) + Math.max(Math.abs(min.z), Math.abs(max.z)));
return {
min: minVertices,
max: maxVertices
};
}
computeInitialHull() {
const vertices = this.vertices;
const extremes = this.computeExtremes();
const min = extremes.min;
const max = extremes.max;
let maxDistance = 0;
let index = 0;
for (let i = 0; i < 3; i++) {
const distance = max[i].point.getComponent(i) - min[i].point.getComponent(i);
if (distance > maxDistance) {
maxDistance = distance;
index = i;
}
}
const v0 = min[index];
const v1 = max[index];
let v2;
let v3;
maxDistance = 0;
_line3.set(v0.point, v1.point);
for (let i = 0, l = this.vertices.length; i < l; i++) {
const vertex = vertices[i];
if (vertex !== v0 && vertex !== v1) {
_line3.closestPointToPoint(vertex.point, true, _closestPoint$1);
const distance = _closestPoint$1.distanceToSquared(vertex.point);
if (distance > maxDistance) {
maxDistance = distance;
v2 = vertex;
}
}
}
maxDistance = -1;
_plane$2.setFromCoplanarPoints(v0.point, v1.point, v2.point);
for (let i = 0, l = this.vertices.length; i < l; i++) {
const vertex = vertices[i];
if (vertex !== v0 && vertex !== v1 && vertex !== v2) {
const distance = Math.abs(_plane$2.distanceToPoint(vertex.point));
if (distance > maxDistance) {
maxDistance = distance;
v3 = vertex;
}
}
}
const faces = [];
if (_plane$2.distanceToPoint(v3.point) < 0) {
faces.push(Face$1.create(v0, v1, v2), Face$1.create(v3, v1, v0), Face$1.create(v3, v2, v1), Face$1.create(v3, v0, v2));
for (let i = 0; i < 3; i++) {
const j = (i + 1) % 3;
faces[i + 1].getEdge(2).setTwin(faces[0].getEdge(j));
faces[i + 1].getEdge(1).setTwin(faces[j + 1].getEdge(0));
}
} else {
faces.push(Face$1.create(v0, v2, v1), Face$1.create(v3, v0, v1), Face$1.create(v3, v1, v2), Face$1.create(v3, v2, v0));
for (let i = 0; i < 3; i++) {
const j = (i + 1) % 3;
faces[i + 1].getEdge(2).setTwin(faces[0].getEdge((3 - i) % 3));
faces[i + 1].getEdge(0).setTwin(faces[j + 1].getEdge(1));
}
}
for (let i = 0; i < 4; i++) this.faces.push(faces[i]);
for (let i = 0, l = vertices.length; i < l; i++) {
const vertex = vertices[i];
if (vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3) {
maxDistance = this.tolerance;
let maxFace = null;
for (let j = 0; j < 4; j++) {
const distance = this.faces[j].distanceToPoint(vertex.point);
if (distance > maxDistance) {
maxDistance = distance;
maxFace = this.faces[j];
}
}
if (maxFace !== null) this.addVertexToFace(vertex, maxFace);
}
}
return this;
}
reindexFaces() {
const activeFaces = [];
for (let i = 0; i < this.faces.length; i++) {
const face = this.faces[i];
if (face.mark === Visible) activeFaces.push(face);
}
this.faces = activeFaces;
return this;
}
nextVertexToAdd() {
if (this.assigned.isEmpty() === false) {
let eyeVertex, maxDistance = 0;
const eyeFace = this.assigned.first().face;
let vertex = eyeFace.outside;
do {
const distance = eyeFace.distanceToPoint(vertex.point);
if (distance > maxDistance) {
maxDistance = distance;
eyeVertex = vertex;
}
vertex = vertex.next;
} while (vertex !== null && vertex.face === eyeFace);
return eyeVertex;
}
}
computeHorizon(eyePoint, crossEdge, face, horizon) {
this.deleteFaceVertices(face);
face.mark = Deleted;
let edge;
if (crossEdge === null) edge = crossEdge = face.getEdge(0);
else edge = crossEdge.next;
do {
const twinEdge = edge.twin;
const oppositeFace = twinEdge.face;
if (oppositeFace.mark === Visible) if (oppositeFace.distanceToPoint(eyePoint) > this.tolerance) this.computeHorizon(eyePoint, twinEdge, oppositeFace, horizon);
else horizon.push(edge);
edge = edge.next;
} while (edge !== crossEdge);
return this;
}
addAdjoiningFace(eyeVertex, horizonEdge) {
const face = Face$1.create(eyeVertex, horizonEdge.tail(), horizonEdge.head());
this.faces.push(face);
face.getEdge(-1).setTwin(horizonEdge.twin);
return face.getEdge(0);
}
addNewFaces(eyeVertex, horizon) {
this.newFaces = [];
let firstSideEdge = null;
let previousSideEdge = null;
for (let i = 0; i < horizon.length; i++) {
const horizonEdge = horizon[i];
const sideEdge = this.addAdjoiningFace(eyeVertex, horizonEdge);
if (firstSideEdge === null) firstSideEdge = sideEdge;
else sideEdge.next.setTwin(previousSideEdge);
this.newFaces.push(sideEdge.face);
previousSideEdge = sideEdge;
}
firstSideEdge.next.setTwin(previousSideEdge);
return this;
}
addVertexToHull(eyeVertex) {
const horizon = [];
this.unassigned.clear();
this.removeVertexFromFace(eyeVertex, eyeVertex.face);
this.computeHorizon(eyeVertex.point, null, eyeVertex.face, horizon);
this.addNewFaces(eyeVertex, horizon);
this.resolveUnassignedPoints(this.newFaces);
return this;
}
cleanup() {
this.assigned.clear();
this.unassigned.clear();
this.newFaces = [];
return this;
}
compute() {
let vertex;
this.computeInitialHull();
while ((vertex = this.nextVertexToAdd()) !== void 0) this.addVertexToHull(vertex);
this.reindexFaces();
this.cleanup();
return this;
}
};
var Face$1 = /* @__PURE__ */ (() => {
class Face2 {
constructor() {
this.normal = new Vector3();
this.midpoint = new Vector3();
this.area = 0;
this.constant = 0;
this.outside = null;
this.mark = Visible;
this.edge = null;
}
static create(a, b, c) {
const face = new Face2();
const e0 = new HalfEdge(a, face);
const e1 = new HalfEdge(b, face);
const e2 = new HalfEdge(c, face);
e0.next = e2.prev = e1;
e1.next = e0.prev = e2;
e2.next = e1.prev = e0;
face.edge = e0;
return face.compute();
}
getEdge(i) {
let edge = this.edge;
while (i > 0) {
edge = edge.next;
i--;
}
while (i < 0) {
edge = edge.prev;
i++;
}
return edge;
}
compute() {
const a = this.edge.tail();
const b = this.edge.head();
const c = this.edge.next.head();
_triangle.set(a.point, b.point, c.point);
_triangle.getNormal(this.normal);
_triangle.getMidpoint(this.midpoint);
this.area = _triangle.getArea();
this.constant = this.normal.dot(this.midpoint);
return this;
}
distanceToPoint(point) {
return this.normal.dot(point) - this.constant;
}
}
return Face2;
})();
var HalfEdge = class {
constructor(vertex, face) {
this.vertex = vertex;
this.prev = null;
this.next = null;
this.twin = null;
this.face = face;
}
head() {
return this.vertex;
}
tail() {
return this.prev ? this.prev.vertex : null;
}
length() {
const head = this.head();
const tail = this.tail();
if (tail !== null) return tail.point.distanceTo(head.point);
return -1;
}
lengthSquared() {
const head = this.head();
const tail = this.tail();
if (tail !== null) return tail.point.distanceToSquared(head.point);
return -1;
}
setTwin(edge) {
this.twin = edge;
edge.twin = this;
return this;
}
};
var VertexNode = class {
constructor(point) {
this.point = point;
this.prev = null;
this.next = null;
this.face = null;
}
};
var VertexList = class {
constructor() {
this.head = null;
this.tail = null;
}
first() {
return this.head;
}
last() {
return this.tail;
}
clear() {
this.head = this.tail = null;
return this;
}
insertBefore(target, vertex) {
vertex.prev = target.prev;
vertex.next = target;
if (vertex.prev === null) this.head = vertex;
else vertex.prev.next = vertex;
target.prev = vertex;
return this;
}
insertAfter(target, vertex) {
vertex.prev = target;
vertex.next = target.next;
if (vertex.next === null) this.tail = vertex;
else vertex.next.prev = vertex;
target.next = vertex;
return this;
}
append(vertex) {
if (this.head === null) this.head = vertex;
else this.tail.next = vertex;
vertex.prev = this.tail;
vertex.next = null;
this.tail = vertex;
return this;
}
appendChain(vertex) {
if (this.head === null) this.head = vertex;
else this.tail.next = vertex;
vertex.prev = this.tail;
while (vertex.next !== null) vertex = vertex.next;
this.tail = vertex;
return this;
}
remove(vertex) {
if (vertex.prev === null) this.head = vertex.next;
else vertex.prev.next = vertex.next;
if (vertex.next === null) this.tail = vertex.prev;
else vertex.next.prev = vertex.prev;
return this;
}
removeSubList(a, b) {
if (a.prev === null) this.head = b.next;
else a.prev.next = b.next;
if (b.next === null) this.tail = a.prev;
else b.next.prev = a.prev;
return this;
}
isEmpty() {
return this.head === null;
}
};
//#endregion
//#region node_modules/three-stdlib/geometries/ConvexGeometry.js
var ConvexGeometry = class extends BufferGeometry {
constructor(points = []) {
super();
const vertices = [];
const normals = [];
const faces = new ConvexHull().setFromPoints(points).faces;
for (let i = 0; i < faces.length; i++) {
const face = faces[i];
let edge = face.edge;
do {
const point = edge.head().point;
vertices.push(point.x, point.y, point.z);
normals.push(face.normal.x, face.normal.y, face.normal.z);
edge = edge.next;
} while (edge !== face.edge);
}
this.setAttribute("position", new Float32BufferAttribute(vertices, 3));
this.setAttribute("normal", new Float32BufferAttribute(normals, 3));
}
};
//#endregion
//#region node_modules/three-stdlib/misc/ConvexObjectBreaker.js
var _v1$4 = /* @__PURE__ */ new Vector3();
var ConvexObjectBreaker = /* @__PURE__ */ (() => {
class ConvexObjectBreaker2 {
constructor(minSizeForBreak = 1.4, smallDelta = 1e-4) {
this.minSizeForBreak = minSizeForBreak;
this.smallDelta = smallDelta;
this.tempLine1 = new Line3();
this.tempPlane1 = new Plane();
this.tempPlane2 = new Plane();
this.tempPlane_Cut = new Plane();
this.tempCM1 = new Vector3();
this.tempCM2 = new Vector3();
this.tempVector3 = new Vector3();
this.tempVector3_2 = new Vector3();
this.tempVector3_3 = new Vector3();
this.tempVector3_P0 = new Vector3();
this.tempVector3_P1 = new Vector3();
this.tempVector3_P2 = new Vector3();
this.tempVector3_N0 = new Vector3();
this.tempVector3_N1 = new Vector3();
this.tempVector3_AB = new Vector3();
this.tempVector3_CB = new Vector3();
this.tempResultObjects = {
object1: null,
object2: null
};
this.segments = [];
const n = 900;
for (let i = 0; i < n; i++) this.segments[i] = false;
}
prepareBreakableObject(object, mass, velocity, angularVelocity, breakable) {
const userData = object.userData;
userData.mass = mass;
userData.velocity = velocity.clone();
userData.angularVelocity = angularVelocity.clone();
userData.breakable = breakable;
}
subdivideByImpact(object, pointOfImpact, normal, maxRadialIterations, maxRandomIterations) {
const debris = [];
const tempPlane1 = this.tempPlane1;
const tempPlane2 = this.tempPlane2;
this.tempVector3.addVectors(pointOfImpact, normal);
tempPlane1.setFromCoplanarPoints(pointOfImpact, object.position, this.tempVector3);
const maxTotalIterations = maxRandomIterations + maxRadialIterations;
const scope = this;
function subdivideRadial(subObject, startAngle, endAngle, numIterations) {
if (Math.random() < numIterations * .05 || numIterations > maxTotalIterations) {
debris.push(subObject);
return;
}
let angle = Math.PI;
if (numIterations === 0) {
tempPlane2.normal.copy(tempPlane1.normal);
tempPlane2.constant = tempPlane1.constant;
} else if (numIterations <= maxRadialIterations) {
angle = (endAngle - startAngle) * (.2 + .6 * Math.random()) + startAngle;
scope.tempVector3_2.copy(object.position).sub(pointOfImpact).applyAxisAngle(normal, angle).add(pointOfImpact);
tempPlane2.setFromCoplanarPoints(pointOfImpact, scope.tempVector3, scope.tempVector3_2);
} else {
angle = (.5 * (numIterations & 1) + .2 * (2 - Math.random())) * Math.PI;
scope.tempVector3_2.copy(pointOfImpact).sub(subObject.position).applyAxisAngle(normal, angle).add(subObject.position);
scope.tempVector3_3.copy(normal).add(subObject.position);
tempPlane2.setFromCoplanarPoints(subObject.position, scope.tempVector3_3, scope.tempVector3_2);
}
scope.cutByPlane(subObject, tempPlane2, scope.tempResultObjects);
const obj1 = scope.tempResultObjects.object1;
const obj2 = scope.tempResultObjects.object2;
if (obj1) subdivideRadial(obj1, startAngle, angle, numIterations + 1);
if (obj2) subdivideRadial(obj2, angle, endAngle, numIterations + 1);
}
subdivideRadial(object, 0, 2 * Math.PI, 0);
return debris;
}
cutByPlane(object, plane, output) {
const geometry = object.geometry;
const coords = geometry.attributes.position.array;
const normals = geometry.attributes.normal.array;
const numPoints = coords.length / 3;
let numFaces = numPoints / 3;
let indices = geometry.getIndex();
if (indices) {
indices = indices.array;
numFaces = indices.length / 3;
}
function getVertexIndex(faceIdx, vert) {
const idx = faceIdx * 3 + vert;
return indices ? indices[idx] : idx;
}
const points1 = [];
const points2 = [];
const delta = this.smallDelta;
const numPointPairs = numPoints * numPoints;
for (let i = 0; i < numPointPairs; i++) this.segments[i] = false;
const p0 = this.tempVector3_P0;
const p1 = this.tempVector3_P1;
const n0 = this.tempVector3_N0;
const n1 = this.tempVector3_N1;
for (let i = 0; i < numFaces - 1; i++) {
const a1 = getVertexIndex(i, 0);
const b1 = getVertexIndex(i, 1);
const c1 = getVertexIndex(i, 2);
n0.set(normals[a1], normals[a1] + 1, normals[a1] + 2);
for (let j = i + 1; j < numFaces; j++) {
const a2 = getVertexIndex(j, 0);
const b2 = getVertexIndex(j, 1);
const c2 = getVertexIndex(j, 2);
n1.set(normals[a2], normals[a2] + 1, normals[a2] + 2);
if (1 - n0.dot(n1) < delta) {
if (a1 === a2 || a1 === b2 || a1 === c2) if (b1 === a2 || b1 === b2 || b1 === c2) {
this.segments[a1 * numPoints + b1] = true;
this.segments[b1 * numPoints + a1] = true;
} else {
this.segments[c1 * numPoints + a1] = true;
this.segments[a1 * numPoints + c1] = true;
}
else if (b1 === a2 || b1 === b2 || b1 === c2) {
this.segments[c1 * numPoints + b1] = true;
this.segments[b1 * numPoints + c1] = true;
}
}
}
}
const localPlane = this.tempPlane_Cut;
object.updateMatrix();
ConvexObjectBreaker2.transformPlaneToLocalSpace(plane, object.matrix, localPlane);
for (let i = 0; i < numFaces; i++) {
const va = getVertexIndex(i, 0);
const vb = getVertexIndex(i, 1);
const vc = getVertexIndex(i, 2);
for (let segment = 0; segment < 3; segment++) {
const i0 = segment === 0 ? va : segment === 1 ? vb : vc;
const i1 = segment === 0 ? vb : segment === 1 ? vc : va;
if (this.segments[i0 * numPoints + i1]) continue;
this.segments[i0 * numPoints + i1] = true;
this.segments[i1 * numPoints + i0] = true;
p0.set(coords[3 * i0], coords[3 * i0 + 1], coords[3 * i0 + 2]);
p1.set(coords[3 * i1], coords[3 * i1 + 1], coords[3 * i1 + 2]);
let mark0 = 0;
let d = localPlane.distanceToPoint(p0);
if (d > delta) {
mark0 = 2;
points2.push(p0.clone());
} else if (d < -delta) {
mark0 = 1;
points1.push(p0.clone());
} else {
mark0 = 3;
points1.push(p0.clone());
points2.push(p0.clone());
}
let mark1 = 0;
d = localPlane.distanceToPoint(p1);
if (d > delta) {
mark1 = 2;
points2.push(p1.clone());
} else if (d < -delta) {
mark1 = 1;
points1.push(p1.clone());
} else {
mark1 = 3;
points1.push(p1.clone());
points2.push(p1.clone());
}
if (mark0 === 1 && mark1 === 2 || mark0 === 2 && mark1 === 1) {
this.tempLine1.start.copy(p0);
this.tempLine1.end.copy(p1);
let intersection = new Vector3();
intersection = localPlane.intersectLine(this.tempLine1, intersection);
if (intersection === null) {
console.error("Internal error: segment does not intersect plane.");
output.segmentedObject1 = null;
output.segmentedObject2 = null;
return 0;
}
points1.push(intersection);
points2.push(intersection.clone());
}
}
}
const newMass = object.userData.mass * .5;
this.tempCM1.set(0, 0, 0);
let radius1 = 0;
const numPoints1 = points1.length;
if (numPoints1 > 0) {
for (let i = 0; i < numPoints1; i++) this.tempCM1.add(points1[i]);
this.tempCM1.divideScalar(numPoints1);
for (let i = 0; i < numPoints1; i++) {
const p = points1[i];
p.sub(this.tempCM1);
radius1 = Math.max(radius1, p.x, p.y, p.z);
}
this.tempCM1.add(object.position);
}
this.tempCM2.set(0, 0, 0);
let radius2 = 0;
const numPoints2 = points2.length;
if (numPoints2 > 0) {
for (let i = 0; i < numPoints2; i++) this.tempCM2.add(points2[i]);
this.tempCM2.divideScalar(numPoints2);
for (let i = 0; i < numPoints2; i++) {
const p = points2[i];
p.sub(this.tempCM2);
radius2 = Math.max(radius2, p.x, p.y, p.z);
}
this.tempCM2.add(object.position);
}
let object1 = null;
let object2 = null;
let numObjects = 0;
if (numPoints1 > 4) {
object1 = new Mesh(new ConvexGeometry(points1), object.material);
object1.position.copy(this.tempCM1);
object1.quaternion.copy(object.quaternion);
this.prepareBreakableObject(object1, newMass, object.userData.velocity, object.userData.angularVelocity, 2 * radius1 > this.minSizeForBreak);
numObjects++;
}
if (numPoints2 > 4) {
object2 = new Mesh(new ConvexGeometry(points2), object.material);
object2.position.copy(this.tempCM2);
object2.quaternion.copy(object.quaternion);
this.prepareBreakableObject(object2, newMass, object.userData.velocity, object.userData.angularVelocity, 2 * radius2 > this.minSizeForBreak);
numObjects++;
}
output.object1 = object1;
output.object2 = object2;
return numObjects;
}
static transformFreeVector(v, m) {
const x = v.x, y = v.y, z = v.z;
const e = m.elements;
v.x = e[0] * x + e[4] * y + e[8] * z;
v.y = e[1] * x + e[5] * y + e[9] * z;
v.z = e[2] * x + e[6] * y + e[10] * z;
return v;
}
static transformFreeVectorInverse(v, m) {
const x = v.x, y = v.y, z = v.z;
const e = m.elements;
v.x = e[0] * x + e[1] * y + e[2] * z;
v.y = e[4] * x + e[5] * y + e[6] * z;
v.z = e[8] * x + e[9] * y + e[10] * z;
return v;
}
static transformTiedVectorInverse(v, m) {
const x = v.x, y = v.y, z = v.z;
const e = m.elements;
v.x = e[0] * x + e[1] * y + e[2] * z - e[12];
v.y = e[4] * x + e[5] * y + e[6] * z - e[13];
v.z = e[8] * x + e[9] * y + e[10] * z - e[14];
return v;
}
static transformPlaneToLocalSpace(plane, m, resultPlane) {
resultPlane.normal.copy(plane.normal);
resultPlane.constant = plane.constant;
const referencePoint = ConvexObjectBreaker2.transformTiedVectorInverse(plane.coplanarPoint(_v1$4), m);
ConvexObjectBreaker2.transformFreeVectorInverse(resultPlane.normal, m);
resultPlane.constant = -referencePoint.dot(resultPlane.normal);
}
}
return ConvexObjectBreaker2;
})();
//#endregion
//#region node_modules/three-stdlib/misc/GPUComputationRenderer.js
var GPUComputationRenderer = class {
constructor(sizeX, sizeY, renderer) {
this.variables = [];
this.currentTextureIndex = 0;
let dataType = FloatType;
const scene = new Scene();
const camera = new Camera();
camera.position.z = 1;
const passThruUniforms = { passThruTexture: { value: null } };
const passThruShader = createShaderMaterial(getPassThroughFragmentShader(), passThruUniforms);
const mesh = new Mesh(new PlaneGeometry(2, 2), passThruShader);
scene.add(mesh);
this.setDataType = function(type) {
dataType = type;
return this;
};
this.addVariable = function(variableName, computeFragmentShader, initialValueTexture) {
const variable = {
name: variableName,
initialValueTexture,
material: this.createShaderMaterial(computeFragmentShader),
dependencies: null,
renderTargets: [],
wrapS: null,
wrapT: null,
minFilter: NearestFilter,
magFilter: NearestFilter
};
this.variables.push(variable);
return variable;
};
this.setVariableDependencies = function(variable, dependencies) {
variable.dependencies = dependencies;
};
this.init = function() {
if (renderer.capabilities.isWebGL2 === false && renderer.extensions.has("OES_texture_float") === false) return "No OES_texture_float support for float textures.";
if (renderer.capabilities.maxVertexTextures === 0) return "No support for vertex shader textures.";
for (let i = 0; i < this.variables.length; i++) {
const variable = this.variables[i];
variable.renderTargets[0] = this.createRenderTarget(sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter);
variable.renderTargets[1] = this.createRenderTarget(sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter);
this.renderTexture(variable.initialValueTexture, variable.renderTargets[0]);
this.renderTexture(variable.initialValueTexture, variable.renderTargets[1]);
const material = variable.material;
const uniforms = material.uniforms;
if (variable.dependencies !== null) for (let d = 0; d < variable.dependencies.length; d++) {
const depVar = variable.dependencies[d];
if (depVar.name !== variable.name) {
let found = false;
for (let j = 0; j < this.variables.length; j++) if (depVar.name === this.variables[j].name) {
found = true;
break;
}
if (!found) return "Variable dependency not found. Variable=" + variable.name + ", dependency=" + depVar.name;
}
uniforms[depVar.name] = { value: null };
material.fragmentShader = "\nuniform sampler2D " + depVar.name + ";\n" + material.fragmentShader;
}
}
this.currentTextureIndex = 0;
return null;
};
this.compute = function() {
const currentTextureIndex = this.currentTextureIndex;
const nextTextureIndex = this.currentTextureIndex === 0 ? 1 : 0;
for (let i = 0, il = this.variables.length; i < il; i++) {
const variable = this.variables[i];
if (variable.dependencies !== null) {
const uniforms = variable.material.uniforms;
for (let d = 0, dl = variable.dependencies.length; d < dl; d++) {
const depVar = variable.dependencies[d];
uniforms[depVar.name].value = depVar.renderTargets[currentTextureIndex].texture;
}
}
this.doRenderTarget(variable.material, variable.renderTargets[nextTextureIndex]);
}
this.currentTextureIndex = nextTextureIndex;
};
this.getCurrentRenderTarget = function(variable) {
return variable.renderTargets[this.currentTextureIndex];
};
this.getAlternateRenderTarget = function(variable) {
return variable.renderTargets[this.currentTextureIndex === 0 ? 1 : 0];
};
this.dispose = function() {
mesh.geometry.dispose();
mesh.material.dispose();
const variables = this.variables;
for (let i = 0; i < variables.length; i++) {
const variable = variables[i];
if (variable.initialValueTexture) variable.initialValueTexture.dispose();
const renderTargets = variable.renderTargets;
for (let j = 0; j < renderTargets.length; j++) renderTargets[j].dispose();
}
};
function addResolutionDefine(materialShader) {
materialShader.defines.resolution = "vec2( " + sizeX.toFixed(1) + ", " + sizeY.toFixed(1) + " )";
}
this.addResolutionDefine = addResolutionDefine;
function createShaderMaterial(computeFragmentShader, uniforms) {
uniforms = uniforms || {};
const material = new ShaderMaterial({
uniforms,
vertexShader: getPassThroughVertexShader(),
fragmentShader: computeFragmentShader
});
addResolutionDefine(material);
return material;
}
this.createShaderMaterial = createShaderMaterial;
this.createRenderTarget = function(sizeXTexture, sizeYTexture, wrapS, wrapT, minFilter, magFilter) {
sizeXTexture = sizeXTexture || sizeX;
sizeYTexture = sizeYTexture || sizeY;
wrapS = wrapS || 1001;
wrapT = wrapT || 1001;
minFilter = minFilter || 1003;
magFilter = magFilter || 1003;
return new WebGLRenderTarget(sizeXTexture, sizeYTexture, {
wrapS,
wrapT,
minFilter,
magFilter,
format: RGBAFormat,
type: dataType,
depthBuffer: false
});
};
this.createTexture = function() {
const texture = new DataTexture(new Float32Array(sizeX * sizeY * 4), sizeX, sizeY, RGBAFormat, FloatType);
texture.needsUpdate = true;
return texture;
};
this.renderTexture = function(input, output) {
passThruUniforms.passThruTexture.value = input;
this.doRenderTarget(passThruShader, output);
passThruUniforms.passThruTexture.value = null;
};
this.doRenderTarget = function(material, output) {
const currentRenderTarget = renderer.getRenderTarget();
const currentXrEnabled = renderer.xr.enabled;
const currentShadowAutoUpdate = renderer.shadowMap.autoUpdate;
const currentOutputColorSpace = renderer.outputColorSpace;
const currentToneMapping = renderer.toneMapping;
renderer.xr.enabled = false;
renderer.shadowMap.autoUpdate = false;
if ("outputColorSpace" in renderer) renderer.outputColorSpace = "srgb-linear";
else renderer.encoding = 3e3;
renderer.toneMapping = 0;
mesh.material = material;
renderer.setRenderTarget(output);
renderer.render(scene, camera);
mesh.material = passThruShader;
renderer.xr.enabled = currentXrEnabled;
renderer.shadowMap.autoUpdate = currentShadowAutoUpdate;
renderer.outputColorSpace = currentOutputColorSpace;
renderer.toneMapping = currentToneMapping;
renderer.setRenderTarget(currentRenderTarget);
};
function getPassThroughVertexShader() {
return "void main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}\n";
}
function getPassThroughFragmentShader() {
return "uniform sampler2D passThruTexture;\n\nvoid main() {\n\n vec2 uv = gl_FragCoord.xy / resolution.xy;\n\n gl_FragColor = texture2D( passThruTexture, uv );\n\n}\n";
}
}
};
//#endregion
//#region node_modules/three-stdlib/misc/Gyroscope.js
var _translationObject = /* @__PURE__ */ new Vector3();
var _quaternionObject = /* @__PURE__ */ new Quaternion();
var _scaleObject = /* @__PURE__ */ new Vector3();
var _translationWorld = /* @__PURE__ */ new Vector3();
var _quaternionWorld = /* @__PURE__ */ new Quaternion();
var _scaleWorld = /* @__PURE__ */ new Vector3();
var Gyroscope = class extends Object3D {
constructor() {
super();
}
updateMatrixWorld(force) {
this.matrixAutoUpdate && this.updateMatrix();
if (this.matrixWorldNeedsUpdate || force) {
if (this.parent !== null) {
this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);
this.matrixWorld.decompose(_translationWorld, _quaternionWorld, _scaleWorld);
this.matrix.decompose(_translationObject, _quaternionObject, _scaleObject);
this.matrixWorld.compose(_translationWorld, _quaternionObject, _scaleWorld);
} else this.matrixWorld.copy(this.matrix);
this.matrixWorldNeedsUpdate = false;
force = true;
}
for (let i = 0, l = this.children.length; i < l; i++) this.children[i].updateMatrixWorld(force);
}
};
//#endregion
//#region node_modules/three-stdlib/misc/MorphAnimMesh.js
var MorphAnimMesh = class extends Mesh {
constructor(geometry, material) {
super(geometry, material);
this.type = "MorphAnimMesh";
this.mixer = new AnimationMixer(this);
this.activeAction = null;
}
setDirectionForward() {
this.mixer.timeScale = 1;
}
setDirectionBackward() {
this.mixer.timeScale = -1;
}
playAnimation(label, fps) {
if (this.activeAction) {
this.activeAction.stop();
this.activeAction = null;
}
const clip = AnimationClip.findByName(this, label);
if (clip) {
const action = this.mixer.clipAction(clip);
action.timeScale = clip.tracks.length * fps / clip.duration;
this.activeAction = action.play();
} else throw new Error("THREE.MorphAnimMesh: animations[" + label + "] undefined in .playAnimation()");
}
updateAnimation(delta) {
this.mixer.update(delta);
}
copy(source, recursive) {
super.copy(source, recursive);
this.mixer = new AnimationMixer(this);
return this;
}
};
//#endregion
//#region node_modules/three-stdlib/misc/RollerCoaster.js
var RollerCoasterGeometry = class extends BufferGeometry {
constructor(curve, divisions) {
super();
const vertices = [];
const normals = [];
const colors = [];
const color1 = [
1,
1,
1
];
const color2 = [
1,
1,
0
];
const up = new Vector3(0, 1, 0);
const forward = new Vector3();
const right = new Vector3();
const quaternion = new Quaternion();
const prevQuaternion = new Quaternion();
prevQuaternion.setFromAxisAngle(up, Math.PI / 2);
const point = new Vector3();
const prevPoint = new Vector3();
prevPoint.copy(curve.getPointAt(0));
const step = [
new Vector3(-.225, 0, 0),
new Vector3(0, -.05, 0),
new Vector3(0, -.175, 0),
new Vector3(0, -.05, 0),
new Vector3(.225, 0, 0),
new Vector3(0, -.175, 0)
];
const PI2 = Math.PI * 2;
let sides = 5;
const tube1 = [];
for (let i = 0; i < sides; i++) {
const angle = i / sides * PI2;
tube1.push(new Vector3(Math.sin(angle) * .06, Math.cos(angle) * .06, 0));
}
sides = 6;
const tube2 = [];
for (let i = 0; i < sides; i++) {
const angle = i / sides * PI2;
tube2.push(new Vector3(Math.sin(angle) * .025, Math.cos(angle) * .025, 0));
}
const vector = new Vector3();
const normal = new Vector3();
function drawShape(shape, color) {
normal.set(0, 0, -1).applyQuaternion(quaternion);
for (let j = 0; j < shape.length; j++) {
vector.copy(shape[j]);
vector.applyQuaternion(quaternion);
vector.add(point);
vertices.push(vector.x, vector.y, vector.z);
normals.push(normal.x, normal.y, normal.z);
colors.push(color[0], color[1], color[2]);
}
normal.set(0, 0, 1).applyQuaternion(quaternion);
for (let j = shape.length - 1; j >= 0; j--) {
vector.copy(shape[j]);
vector.applyQuaternion(quaternion);
vector.add(point);
vertices.push(vector.x, vector.y, vector.z);
normals.push(normal.x, normal.y, normal.z);
colors.push(color[0], color[1], color[2]);
}
}
const vector1 = new Vector3();
const vector2 = new Vector3();
const vector3 = new Vector3();
const vector4 = new Vector3();
const normal1 = new Vector3();
const normal2 = new Vector3();
const normal3 = new Vector3();
const normal4 = new Vector3();
function extrudeShape(shape, offset2, color) {
for (let j = 0, jl = shape.length; j < jl; j++) {
const point1 = shape[j];
const point2 = shape[(j + 1) % jl];
vector1.copy(point1).add(offset2);
vector1.applyQuaternion(quaternion);
vector1.add(point);
vector2.copy(point2).add(offset2);
vector2.applyQuaternion(quaternion);
vector2.add(point);
vector3.copy(point2).add(offset2);
vector3.applyQuaternion(prevQuaternion);
vector3.add(prevPoint);
vector4.copy(point1).add(offset2);
vector4.applyQuaternion(prevQuaternion);
vector4.add(prevPoint);
vertices.push(vector1.x, vector1.y, vector1.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector4.x, vector4.y, vector4.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector3.x, vector3.y, vector3.z);
vertices.push(vector4.x, vector4.y, vector4.z);
normal1.copy(point1);
normal1.applyQuaternion(quaternion);
normal1.normalize();
normal2.copy(point2);
normal2.applyQuaternion(quaternion);
normal2.normalize();
normal3.copy(point2);
normal3.applyQuaternion(prevQuaternion);
normal3.normalize();
normal4.copy(point1);
normal4.applyQuaternion(prevQuaternion);
normal4.normalize();
normals.push(normal1.x, normal1.y, normal1.z);
normals.push(normal2.x, normal2.y, normal2.z);
normals.push(normal4.x, normal4.y, normal4.z);
normals.push(normal2.x, normal2.y, normal2.z);
normals.push(normal3.x, normal3.y, normal3.z);
normals.push(normal4.x, normal4.y, normal4.z);
colors.push(color[0], color[1], color[2]);
colors.push(color[0], color[1], color[2]);
colors.push(color[0], color[1], color[2]);
colors.push(color[0], color[1], color[2]);
colors.push(color[0], color[1], color[2]);
colors.push(color[0], color[1], color[2]);
}
}
const offset = new Vector3();
for (let i = 1; i <= divisions; i++) {
point.copy(curve.getPointAt(i / divisions));
up.set(0, 1, 0);
forward.subVectors(point, prevPoint).normalize();
right.crossVectors(up, forward).normalize();
up.crossVectors(forward, right);
const angle = Math.atan2(forward.x, forward.z);
quaternion.setFromAxisAngle(up, angle);
if (i % 2 === 0) drawShape(step, color2);
extrudeShape(tube1, offset.set(0, -.125, 0), color2);
extrudeShape(tube2, offset.set(.2, 0, 0), color1);
extrudeShape(tube2, offset.set(-.2, 0, 0), color1);
prevPoint.copy(point);
prevQuaternion.copy(quaternion);
}
this.setAttribute("position", new BufferAttribute(new Float32Array(vertices), 3));
this.setAttribute("normal", new BufferAttribute(new Float32Array(normals), 3));
this.setAttribute("color", new BufferAttribute(new Float32Array(colors), 3));
}
};
var RollerCoasterLiftersGeometry = class extends BufferGeometry {
constructor(curve, divisions) {
super();
const vertices = [];
const normals = [];
const quaternion = new Quaternion();
const up = new Vector3(0, 1, 0);
const point = new Vector3();
const tangent = new Vector3();
const tube1 = [
new Vector3(0, .05, -.05),
new Vector3(0, .05, .05),
new Vector3(0, -.05, 0)
];
const tube2 = [
new Vector3(-.05, 0, .05),
new Vector3(-.05, 0, -.05),
new Vector3(.05, 0, 0)
];
const tube3 = [
new Vector3(.05, 0, -.05),
new Vector3(.05, 0, .05),
new Vector3(-.05, 0, 0)
];
const vector1 = new Vector3();
const vector2 = new Vector3();
const vector3 = new Vector3();
const vector4 = new Vector3();
const normal1 = new Vector3();
const normal2 = new Vector3();
const normal3 = new Vector3();
const normal4 = new Vector3();
function extrudeShape(shape, fromPoint2, toPoint2) {
for (let j = 0, jl = shape.length; j < jl; j++) {
const point1 = shape[j];
const point2 = shape[(j + 1) % jl];
vector1.copy(point1);
vector1.applyQuaternion(quaternion);
vector1.add(fromPoint2);
vector2.copy(point2);
vector2.applyQuaternion(quaternion);
vector2.add(fromPoint2);
vector3.copy(point2);
vector3.applyQuaternion(quaternion);
vector3.add(toPoint2);
vector4.copy(point1);
vector4.applyQuaternion(quaternion);
vector4.add(toPoint2);
vertices.push(vector1.x, vector1.y, vector1.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector4.x, vector4.y, vector4.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector3.x, vector3.y, vector3.z);
vertices.push(vector4.x, vector4.y, vector4.z);
normal1.copy(point1);
normal1.applyQuaternion(quaternion);
normal1.normalize();
normal2.copy(point2);
normal2.applyQuaternion(quaternion);
normal2.normalize();
normal3.copy(point2);
normal3.applyQuaternion(quaternion);
normal3.normalize();
normal4.copy(point1);
normal4.applyQuaternion(quaternion);
normal4.normalize();
normals.push(normal1.x, normal1.y, normal1.z);
normals.push(normal2.x, normal2.y, normal2.z);
normals.push(normal4.x, normal4.y, normal4.z);
normals.push(normal2.x, normal2.y, normal2.z);
normals.push(normal3.x, normal3.y, normal3.z);
normals.push(normal4.x, normal4.y, normal4.z);
}
}
const fromPoint = new Vector3();
const toPoint = new Vector3();
for (let i = 1; i <= divisions; i++) {
point.copy(curve.getPointAt(i / divisions));
tangent.copy(curve.getTangentAt(i / divisions));
const angle = Math.atan2(tangent.x, tangent.z);
quaternion.setFromAxisAngle(up, angle);
if (point.y > 10) {
fromPoint.set(-.75, -.35, 0);
fromPoint.applyQuaternion(quaternion);
fromPoint.add(point);
toPoint.set(.75, -.35, 0);
toPoint.applyQuaternion(quaternion);
toPoint.add(point);
extrudeShape(tube1, fromPoint, toPoint);
fromPoint.set(-.7, -.3, 0);
fromPoint.applyQuaternion(quaternion);
fromPoint.add(point);
toPoint.set(-.7, -point.y, 0);
toPoint.applyQuaternion(quaternion);
toPoint.add(point);
extrudeShape(tube2, fromPoint, toPoint);
fromPoint.set(.7, -.3, 0);
fromPoint.applyQuaternion(quaternion);
fromPoint.add(point);
toPoint.set(.7, -point.y, 0);
toPoint.applyQuaternion(quaternion);
toPoint.add(point);
extrudeShape(tube3, fromPoint, toPoint);
} else {
fromPoint.set(0, -.2, 0);
fromPoint.applyQuaternion(quaternion);
fromPoint.add(point);
toPoint.set(0, -point.y, 0);
toPoint.applyQuaternion(quaternion);
toPoint.add(point);
extrudeShape(tube3, fromPoint, toPoint);
}
}
this.setAttribute("position", new BufferAttribute(new Float32Array(vertices), 3));
this.setAttribute("normal", new BufferAttribute(new Float32Array(normals), 3));
}
};
var RollerCoasterShadowGeometry = class extends BufferGeometry {
constructor(curve, divisions) {
super();
const vertices = [];
const up = new Vector3(0, 1, 0);
const forward = new Vector3();
const quaternion = new Quaternion();
const prevQuaternion = new Quaternion();
prevQuaternion.setFromAxisAngle(up, Math.PI / 2);
const point = new Vector3();
const prevPoint = new Vector3();
prevPoint.copy(curve.getPointAt(0));
prevPoint.y = 0;
const vector1 = new Vector3();
const vector2 = new Vector3();
const vector3 = new Vector3();
const vector4 = new Vector3();
for (let i = 1; i <= divisions; i++) {
point.copy(curve.getPointAt(i / divisions));
point.y = 0;
forward.subVectors(point, prevPoint);
const angle = Math.atan2(forward.x, forward.z);
quaternion.setFromAxisAngle(up, angle);
vector1.set(-.3, 0, 0);
vector1.applyQuaternion(quaternion);
vector1.add(point);
vector2.set(.3, 0, 0);
vector2.applyQuaternion(quaternion);
vector2.add(point);
vector3.set(.3, 0, 0);
vector3.applyQuaternion(prevQuaternion);
vector3.add(prevPoint);
vector4.set(-.3, 0, 0);
vector4.applyQuaternion(prevQuaternion);
vector4.add(prevPoint);
vertices.push(vector1.x, vector1.y, vector1.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector4.x, vector4.y, vector4.z);
vertices.push(vector2.x, vector2.y, vector2.z);
vertices.push(vector3.x, vector3.y, vector3.z);
vertices.push(vector4.x, vector4.y, vector4.z);
prevPoint.copy(point);
prevQuaternion.copy(quaternion);
}
this.setAttribute("position", new BufferAttribute(new Float32Array(vertices), 3));
}
};
var SkyGeometry = class extends BufferGeometry {
constructor() {
super();
const vertices = [];
for (let i = 0; i < 100; i++) {
const x = Math.random() * 800 - 400;
const y = Math.random() * 50 + 50;
const z = Math.random() * 800 - 400;
const size = Math.random() * 40 + 20;
vertices.push(x - size, y, z - size);
vertices.push(x + size, y, z - size);
vertices.push(x - size, y, z + size);
vertices.push(x + size, y, z - size);
vertices.push(x + size, y, z + size);
vertices.push(x - size, y, z + size);
}
this.setAttribute("position", new BufferAttribute(new Float32Array(vertices), 3));
}
};
var TreesGeometry = class extends BufferGeometry {
constructor(landscape) {
super();
const vertices = [];
const colors = [];
const raycaster = new Raycaster();
raycaster.ray.direction.set(0, -1, 0);
const _color = new Color();
for (let i = 0; i < 2e3; i++) {
const x = Math.random() * 500 - 250;
const z = Math.random() * 500 - 250;
raycaster.ray.origin.set(x, 50, z);
const intersections = raycaster.intersectObject(landscape);
if (intersections.length === 0) continue;
const y = intersections[0].point.y;
const height = Math.random() * 5 + .5;
let angle = Math.random() * Math.PI * 2;
vertices.push(x + Math.sin(angle), y, z + Math.cos(angle));
vertices.push(x, y + height, z);
vertices.push(x + Math.sin(angle + Math.PI), y, z + Math.cos(angle + Math.PI));
angle += Math.PI / 2;
vertices.push(x + Math.sin(angle), y, z + Math.cos(angle));
vertices.push(x, y + height, z);
vertices.push(x + Math.sin(angle + Math.PI), y, z + Math.cos(angle + Math.PI));
const random = Math.random() * .1;
for (let j = 0; j < 6; j++) {
_color.setRGB(.2 + random, .4 + random, 0, "srgb");
colors.push(_color.r, _color.g, _color.b);
}
}
this.setAttribute("position", new BufferAttribute(new Float32Array(vertices), 3));
this.setAttribute("color", new BufferAttribute(new Float32Array(colors), 3));
}
};
//#endregion
//#region node_modules/three-stdlib/misc/Timer.js
var __defProp$59 = Object.defineProperty;
var __defNormalProp$59 = (obj, key, value) => key in obj ? __defProp$59(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$59 = (obj, key, value) => {
__defNormalProp$59(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var Timer = class {
constructor() {
__publicField$59(this, "_previousTime");
__publicField$59(this, "_currentTime");
__publicField$59(this, "_delta");
__publicField$59(this, "_elapsed");
__publicField$59(this, "_timescale");
__publicField$59(this, "_useFixedDelta");
__publicField$59(this, "_fixedDelta");
__publicField$59(this, "_usePageVisibilityAPI");
__publicField$59(this, "_pageVisibilityHandler");
this._previousTime = 0;
this._currentTime = 0;
this._delta = 0;
this._elapsed = 0;
this._timescale = 1;
this._useFixedDelta = false;
this._fixedDelta = 16.67;
this._usePageVisibilityAPI = typeof document !== "undefined" && document.hidden !== void 0;
}
connect() {
if (this._usePageVisibilityAPI) {
this._pageVisibilityHandler = handleVisibilityChange.bind(this);
document.addEventListener("visibilitychange", this._pageVisibilityHandler, false);
}
return this;
}
dispose() {
if (this._usePageVisibilityAPI && this._pageVisibilityHandler) document.removeEventListener("visibilitychange", this._pageVisibilityHandler);
return this;
}
disableFixedDelta() {
this._useFixedDelta = false;
return this;
}
enableFixedDelta() {
this._useFixedDelta = true;
return this;
}
getDelta() {
return this._delta / 1e3;
}
getElapsedTime() {
return this._elapsed / 1e3;
}
getFixedDelta() {
return this._fixedDelta / 1e3;
}
getTimescale() {
return this._timescale;
}
reset() {
this._currentTime = this._now();
return this;
}
setFixedDelta(fixedDelta) {
this._fixedDelta = fixedDelta * 1e3;
return this;
}
setTimescale(timescale) {
this._timescale = timescale;
return this;
}
update() {
if (this._useFixedDelta === true) this._delta = this._fixedDelta;
else {
this._previousTime = this._currentTime;
this._currentTime = this._now();
this._delta = this._currentTime - this._previousTime;
}
this._delta *= this._timescale;
this._elapsed += this._delta;
return this;
}
get elapsedTime() {
return this.getElapsedTime();
}
_now() {
return (typeof performance === "undefined" ? Date : performance).now();
}
};
function handleVisibilityChange() {
if (document.hidden === false) this.reset();
}
//#endregion
//#region node_modules/three-stdlib/misc/WebGL.js
var webGLAvailable, webGL2Available;
function isWebGLAvailable() {
var _a;
if (webGLAvailable !== void 0) return webGLAvailable;
try {
let gl;
const canvas = document.createElement("canvas");
webGLAvailable = !!(window.WebGLRenderingContext && (gl = canvas.getContext("webgl")));
if (gl) (_a = gl.getExtension("WEBGL_lose_context")) == null || _a.loseContext();
return webGLAvailable;
} catch (e) {
return webGLAvailable = false;
}
}
function isWebGL2Available() {
var _a;
if (webGL2Available !== void 0) return webGL2Available;
try {
let gl;
const canvas = document.createElement("canvas");
webGL2Available = !!(window.WebGL2RenderingContext && (gl = canvas.getContext("webgl2")));
if (gl) (_a = gl.getExtension("WEBGL_lose_context")) == null || _a.loseContext();
return webGL2Available;
} catch (e) {
return webGL2Available = false;
}
}
function getWebGLErrorMessage() {
return getErrorMessage(1);
}
function getWebGL2ErrorMessage() {
return getErrorMessage(2);
}
function getErrorMessage(version) {
const names = {
1: "WebGL",
2: "WebGL 2"
};
const contexts = {
1: window.WebGLRenderingContext,
2: window.WebGL2RenderingContext
};
const element = document.createElement("div");
element.id = "webglmessage";
element.style.fontFamily = "monospace";
element.style.fontSize = "13px";
element.style.fontWeight = "normal";
element.style.textAlign = "center";
element.style.background = "#fff";
element.style.color = "#000";
element.style.padding = "1.5em";
element.style.width = "400px";
element.style.margin = "5em auto 0";
let message = "Your $0 does not seem to support $1";
if (contexts[version]) message = message.replace("$0", "graphics card");
else message = message.replace("$0", "browser");
message = message.replace("$1", names[version]);
element.innerHTML = message;
return element;
}
//#endregion
//#region node_modules/three-stdlib/misc/MD2Character.js
var MD2Character = class {
constructor() {
this.scale = 1;
this.animationFPS = 6;
this.root = new Object3D();
this.meshBody = null;
this.meshWeapon = null;
this.skinsBody = [];
this.skinsWeapon = [];
this.weapons = [];
this.activeAnimation = null;
this.mixer = null;
this.onLoadComplete = function() {};
this.loadCounter = 0;
}
loadParts(config) {
const scope = this;
function createPart(geometry, skinMap) {
const materialWireframe = new MeshLambertMaterial({
color: 16755200,
wireframe: true,
morphTargets: true,
morphNormals: true
});
const materialTexture = new MeshLambertMaterial({
color: 16777215,
wireframe: false,
map: skinMap,
morphTargets: true,
morphNormals: true
});
const mesh = new Mesh(geometry, materialTexture);
mesh.rotation.y = -Math.PI / 2;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.materialTexture = materialTexture;
mesh.materialWireframe = materialWireframe;
return mesh;
}
function loadTextures(baseUrl, textureUrls) {
const textureLoader = new TextureLoader();
const textures = [];
for (let i = 0; i < textureUrls.length; i++) {
textures[i] = textureLoader.load(baseUrl + textureUrls[i], checkLoadingComplete);
textures[i].mapping = 300;
textures[i].name = textureUrls[i];
if ("colorSpace" in textures[i]) textures[i].colorSpace = "srgb";
else textures[i].encoding = 3001;
}
return textures;
}
function checkLoadingComplete() {
scope.loadCounter -= 1;
if (scope.loadCounter === 0) scope.onLoadComplete();
}
this.loadCounter = config.weapons.length * 2 + config.skins.length + 1;
const weaponsTextures = [];
for (let i = 0; i < config.weapons.length; i++) weaponsTextures[i] = config.weapons[i][1];
this.skinsBody = loadTextures(config.baseUrl + "skins/", config.skins);
this.skinsWeapon = loadTextures(config.baseUrl + "skins/", weaponsTextures);
const loader = new MD2Loader();
loader.load(config.baseUrl + config.body, function(geo) {
const boundingBox = new Box3();
boundingBox.setFromBufferAttribute(geo.attributes.position);
scope.root.position.y = -scope.scale * boundingBox.min.y;
const mesh = createPart(geo, scope.skinsBody[0]);
mesh.scale.set(scope.scale, scope.scale, scope.scale);
scope.root.add(mesh);
scope.meshBody = mesh;
scope.meshBody.clipOffset = 0;
scope.activeAnimationClipName = mesh.geometry.animations[0].name;
scope.mixer = new AnimationMixer(mesh);
checkLoadingComplete();
});
const generateCallback = function(index, name) {
return function(geo) {
const mesh = createPart(geo, scope.skinsWeapon[index]);
mesh.scale.set(scope.scale, scope.scale, scope.scale);
mesh.visible = false;
mesh.name = name;
scope.root.add(mesh);
scope.weapons[index] = mesh;
scope.meshWeapon = mesh;
checkLoadingComplete();
};
};
for (let i = 0; i < config.weapons.length; i++) loader.load(config.baseUrl + config.weapons[i][0], generateCallback(i, config.weapons[i][0]));
}
setPlaybackRate(rate) {
if (rate !== 0) this.mixer.timeScale = 1 / rate;
else this.mixer.timeScale = 0;
}
setWireframe(wireframeEnabled) {
if (wireframeEnabled) {
if (this.meshBody) this.meshBody.material = this.meshBody.materialWireframe;
if (this.meshWeapon) this.meshWeapon.material = this.meshWeapon.materialWireframe;
} else {
if (this.meshBody) this.meshBody.material = this.meshBody.materialTexture;
if (this.meshWeapon) this.meshWeapon.material = this.meshWeapon.materialTexture;
}
}
setSkin(index) {
if (this.meshBody && this.meshBody.material.wireframe === false) this.meshBody.material.map = this.skinsBody[index];
}
setWeapon(index) {
for (let i = 0; i < this.weapons.length; i++) this.weapons[i].visible = false;
const activeWeapon = this.weapons[index];
if (activeWeapon) {
activeWeapon.visible = true;
this.meshWeapon = activeWeapon;
this.syncWeaponAnimation();
}
}
setAnimation(clipName) {
if (this.meshBody) {
if (this.meshBody.activeAction) {
this.meshBody.activeAction.stop();
this.meshBody.activeAction = null;
}
const action = this.mixer.clipAction(clipName, this.meshBody);
if (action) this.meshBody.activeAction = action.play();
}
this.activeClipName = clipName;
this.syncWeaponAnimation();
}
syncWeaponAnimation() {
const clipName = this.activeClipName;
if (this.meshWeapon) {
if (this.meshWeapon.activeAction) {
this.meshWeapon.activeAction.stop();
this.meshWeapon.activeAction = null;
}
const action = this.mixer.clipAction(clipName, this.meshWeapon);
if (action) this.meshWeapon.activeAction = action.syncWith(this.meshBody.activeAction).play();
}
}
update(delta) {
if (this.mixer) this.mixer.update(delta);
}
};
//#endregion
//#region node_modules/three-stdlib/misc/VolumeSlice.js
var VolumeSlice = class {
constructor(volume, index, axis) {
const slice = this;
this.volume = volume;
index = index || 0;
Object.defineProperty(this, "index", {
get: function() {
return index;
},
set: function(value) {
index = value;
slice.geometryNeedsUpdate = true;
return index;
}
});
this.axis = axis || "z";
this.canvas = document.createElement("canvas");
this.canvasBuffer = document.createElement("canvas");
this.updateGeometry();
const canvasMap = new Texture(this.canvas);
canvasMap.minFilter = LinearFilter;
canvasMap.wrapS = canvasMap.wrapT = ClampToEdgeWrapping;
if ("colorSpace" in canvasMap) canvasMap.colorSpace = "srgb";
else canvasMap.encoding = 3001;
const material = new MeshBasicMaterial({
map: canvasMap,
side: 2,
transparent: true
});
this.mesh = new Mesh(this.geometry, material);
this.mesh.matrixAutoUpdate = false;
this.geometryNeedsUpdate = true;
this.repaint();
}
/**
* @member {Function} repaint Refresh the texture and the geometry if geometryNeedsUpdate is set to true
* @memberof VolumeSlice
*/
repaint() {
if (this.geometryNeedsUpdate) this.updateGeometry();
const iLength = this.iLength, jLength = this.jLength, sliceAccess = this.sliceAccess, volume = this.volume, canvas = this.canvasBuffer, ctx = this.ctxBuffer;
const imgData = ctx.getImageData(0, 0, iLength, jLength);
const data = imgData.data;
const volumeData = volume.data;
const upperThreshold = volume.upperThreshold;
const lowerThreshold = volume.lowerThreshold;
const windowLow = volume.windowLow;
const windowHigh = volume.windowHigh;
let pixelCount = 0;
if (volume.dataType === "label") for (let j = 0; j < jLength; j++) for (let i = 0; i < iLength; i++) {
let label = volumeData[sliceAccess(i, j)];
label = label >= this.colorMap.length ? label % this.colorMap.length + 1 : label;
const color = this.colorMap[label];
data[4 * pixelCount] = color >> 24 & 255;
data[4 * pixelCount + 1] = color >> 16 & 255;
data[4 * pixelCount + 2] = color >> 8 & 255;
data[4 * pixelCount + 3] = color & 255;
pixelCount++;
}
else for (let j = 0; j < jLength; j++) for (let i = 0; i < iLength; i++) {
let value = volumeData[sliceAccess(i, j)];
let alpha = 255;
alpha = upperThreshold >= value ? lowerThreshold <= value ? alpha : 0 : 0;
value = Math.floor(255 * (value - windowLow) / (windowHigh - windowLow));
value = value > 255 ? 255 : value < 0 ? 0 : value | 0;
data[4 * pixelCount] = value;
data[4 * pixelCount + 1] = value;
data[4 * pixelCount + 2] = value;
data[4 * pixelCount + 3] = alpha;
pixelCount++;
}
ctx.putImageData(imgData, 0, 0);
this.ctx.drawImage(canvas, 0, 0, iLength, jLength, 0, 0, this.canvas.width, this.canvas.height);
this.mesh.material.map.needsUpdate = true;
}
/**
* @member {Function} Refresh the geometry according to axis and index
* @see Volume.extractPerpendicularPlane
* @memberof VolumeSlice
*/
updateGeometry() {
const extracted = this.volume.extractPerpendicularPlane(this.axis, this.index);
this.sliceAccess = extracted.sliceAccess;
this.jLength = extracted.jLength;
this.iLength = extracted.iLength;
this.matrix = extracted.matrix;
this.canvas.width = extracted.planeWidth;
this.canvas.height = extracted.planeHeight;
this.canvasBuffer.width = this.iLength;
this.canvasBuffer.height = this.jLength;
this.ctx = this.canvas.getContext("2d");
this.ctxBuffer = this.canvasBuffer.getContext("2d");
if (this.geometry) this.geometry.dispose();
this.geometry = new PlaneGeometry(extracted.planeWidth, extracted.planeHeight);
if (this.mesh) {
this.mesh.geometry = this.geometry;
this.mesh.matrix.identity();
this.mesh.applyMatrix4(this.matrix);
}
this.geometryNeedsUpdate = false;
}
};
//#endregion
//#region node_modules/three-stdlib/misc/TubePainter.js
function TubePainter() {
const BUFFER_SIZE = 1e6 * 3;
const positions = new BufferAttribute(new Float32Array(BUFFER_SIZE), 3);
positions.usage = DynamicDrawUsage;
const normals = new BufferAttribute(new Float32Array(BUFFER_SIZE), 3);
normals.usage = DynamicDrawUsage;
const colors = new BufferAttribute(new Float32Array(BUFFER_SIZE), 3);
colors.usage = DynamicDrawUsage;
const geometry = new BufferGeometry();
geometry.setAttribute("position", positions);
geometry.setAttribute("normal", normals);
geometry.setAttribute("color", colors);
geometry.drawRange.count = 0;
const mesh = new Mesh(geometry, new MeshStandardMaterial({ vertexColors: true }));
mesh.frustumCulled = false;
function getPoints(size2) {
const PI2 = Math.PI * 2;
const sides = 10;
const array = [];
const radius = .01 * size2;
for (let i = 0; i < sides; i++) {
const angle = i / sides * PI2;
array.push(new Vector3(Math.sin(angle) * radius, Math.cos(angle) * radius, 0));
}
return array;
}
const vector1 = new Vector3();
const vector2 = new Vector3();
const vector3 = new Vector3();
const vector4 = new Vector3();
const color = new Color(16777215);
let size = 1;
function stroke(position1, position2, matrix12, matrix22) {
if (position1.distanceToSquared(position2) === 0) return;
let count2 = geometry.drawRange.count;
const points = getPoints(size);
for (let i = 0, il = points.length; i < il; i++) {
const vertex1 = points[i];
const vertex2 = points[(i + 1) % il];
vector1.copy(vertex1).applyMatrix4(matrix22).add(position2);
vector2.copy(vertex2).applyMatrix4(matrix22).add(position2);
vector3.copy(vertex2).applyMatrix4(matrix12).add(position1);
vector4.copy(vertex1).applyMatrix4(matrix12).add(position1);
vector1.toArray(positions.array, (count2 + 0) * 3);
vector2.toArray(positions.array, (count2 + 1) * 3);
vector4.toArray(positions.array, (count2 + 2) * 3);
vector2.toArray(positions.array, (count2 + 3) * 3);
vector3.toArray(positions.array, (count2 + 4) * 3);
vector4.toArray(positions.array, (count2 + 5) * 3);
vector1.copy(vertex1).applyMatrix4(matrix22).normalize();
vector2.copy(vertex2).applyMatrix4(matrix22).normalize();
vector3.copy(vertex2).applyMatrix4(matrix12).normalize();
vector4.copy(vertex1).applyMatrix4(matrix12).normalize();
vector1.toArray(normals.array, (count2 + 0) * 3);
vector2.toArray(normals.array, (count2 + 1) * 3);
vector4.toArray(normals.array, (count2 + 2) * 3);
vector2.toArray(normals.array, (count2 + 3) * 3);
vector3.toArray(normals.array, (count2 + 4) * 3);
vector4.toArray(normals.array, (count2 + 5) * 3);
color.toArray(colors.array, (count2 + 0) * 3);
color.toArray(colors.array, (count2 + 1) * 3);
color.toArray(colors.array, (count2 + 2) * 3);
color.toArray(colors.array, (count2 + 3) * 3);
color.toArray(colors.array, (count2 + 4) * 3);
color.toArray(colors.array, (count2 + 5) * 3);
count2 += 6;
}
geometry.drawRange.count = count2;
}
const up = new Vector3(0, 1, 0);
const point1 = new Vector3();
const point2 = new Vector3();
const matrix1 = new Matrix4();
const matrix2 = new Matrix4();
function moveTo(position) {
point1.copy(position);
matrix1.lookAt(point2, point1, up);
point2.copy(position);
matrix2.copy(matrix1);
}
function lineTo(position) {
point1.copy(position);
matrix1.lookAt(point2, point1, up);
stroke(point1, point2, matrix1, matrix2);
point2.copy(point1);
matrix2.copy(matrix1);
}
function setSize(value) {
size = value;
}
let count = 0;
function update() {
const start = count;
const end = geometry.drawRange.count;
if (start === end) return;
positions.updateRange.offset = start * 3;
positions.updateRange.count = (end - start) * 3;
positions.needsUpdate = true;
normals.updateRange.offset = start * 3;
normals.updateRange.count = (end - start) * 3;
normals.needsUpdate = true;
colors.updateRange.offset = start * 3;
colors.updateRange.count = (end - start) * 3;
colors.needsUpdate = true;
count = geometry.drawRange.count;
}
return {
mesh,
moveTo,
lineTo,
setSize,
update
};
}
//#endregion
//#region node_modules/three-stdlib/misc/Volume.js
var Volume = class {
constructor(xLength, yLength, zLength, type, arrayBuffer) {
if (xLength !== void 0) {
this.xLength = Number(xLength) || 1;
this.yLength = Number(yLength) || 1;
this.zLength = Number(zLength) || 1;
this.axisOrder = [
"x",
"y",
"z"
];
switch (type) {
case "Uint8":
case "uint8":
case "uchar":
case "unsigned char":
case "uint8_t":
this.data = new Uint8Array(arrayBuffer);
break;
case "Int8":
case "int8":
case "signed char":
case "int8_t":
this.data = new Int8Array(arrayBuffer);
break;
case "Int16":
case "int16":
case "short":
case "short int":
case "signed short":
case "signed short int":
case "int16_t":
this.data = new Int16Array(arrayBuffer);
break;
case "Uint16":
case "uint16":
case "ushort":
case "unsigned short":
case "unsigned short int":
case "uint16_t":
this.data = new Uint16Array(arrayBuffer);
break;
case "Int32":
case "int32":
case "int":
case "signed int":
case "int32_t":
this.data = new Int32Array(arrayBuffer);
break;
case "Uint32":
case "uint32":
case "uint":
case "unsigned int":
case "uint32_t":
this.data = new Uint32Array(arrayBuffer);
break;
case "longlong":
case "long long":
case "long long int":
case "signed long long":
case "signed long long int":
case "int64":
case "int64_t":
case "ulonglong":
case "unsigned long long":
case "unsigned long long int":
case "uint64":
case "uint64_t": throw new Error("Error in Volume constructor : this type is not supported in JavaScript");
case "Float32":
case "float32":
case "float":
this.data = new Float32Array(arrayBuffer);
break;
case "Float64":
case "float64":
case "double":
this.data = new Float64Array(arrayBuffer);
break;
default: this.data = new Uint8Array(arrayBuffer);
}
if (this.data.length !== this.xLength * this.yLength * this.zLength) throw new Error("Error in Volume constructor, lengths are not matching arrayBuffer size");
}
this.spacing = [
1,
1,
1
];
this.offset = [
0,
0,
0
];
this.matrix = new Matrix3();
this.matrix.identity();
let lowerThreshold = -Infinity;
Object.defineProperty(this, "lowerThreshold", {
get: function() {
return lowerThreshold;
},
set: function(value) {
lowerThreshold = value;
this.sliceList.forEach(function(slice) {
slice.geometryNeedsUpdate = true;
});
}
});
let upperThreshold = Infinity;
Object.defineProperty(this, "upperThreshold", {
get: function() {
return upperThreshold;
},
set: function(value) {
upperThreshold = value;
this.sliceList.forEach(function(slice) {
slice.geometryNeedsUpdate = true;
});
}
});
this.sliceList = [];
this.segmentation = false;
}
/**
* @member {Function} getData Shortcut for data[access(i,j,k)]
* @memberof Volume
* @param {number} i First coordinate
* @param {number} j Second coordinate
* @param {number} k Third coordinate
* @returns {number} value in the data array
*/
getData(i, j, k) {
return this.data[k * this.xLength * this.yLength + j * this.xLength + i];
}
/**
* @member {Function} access compute the index in the data array corresponding to the given coordinates in IJK system
* @memberof Volume
* @param {number} i First coordinate
* @param {number} j Second coordinate
* @param {number} k Third coordinate
* @returns {number} index
*/
access(i, j, k) {
return k * this.xLength * this.yLength + j * this.xLength + i;
}
/**
* @member {Function} reverseAccess Retrieve the IJK coordinates of the voxel corresponding of the given index in the data
* @memberof Volume
* @param {number} index index of the voxel
* @returns {Array} [x,y,z]
*/
reverseAccess(index) {
const z = Math.floor(index / (this.yLength * this.xLength));
const y = Math.floor((index - z * this.yLength * this.xLength) / this.xLength);
return [
index - z * this.yLength * this.xLength - y * this.xLength,
y,
z
];
}
/**
* @member {Function} map Apply a function to all the voxels, be careful, the value will be replaced
* @memberof Volume
* @param {Function} functionToMap A function to apply to every voxel, will be called with the following parameters :
* value of the voxel
* index of the voxel
* the data (TypedArray)
* @param {Object} context You can specify a context in which call the function, default if this Volume
* @returns {Volume} this
*/
map(functionToMap, context) {
const length = this.data.length;
context = context || this;
for (let i = 0; i < length; i++) this.data[i] = functionToMap.call(context, this.data[i], i, this.data);
return this;
}
/**
* @member {Function} extractPerpendicularPlane Compute the orientation of the slice and returns all the information relative to the geometry such as sliceAccess, the plane matrix (orientation and position in RAS coordinate) and the dimensions of the plane in both coordinate system.
* @memberof Volume
* @param {string} axis the normal axis to the slice 'x' 'y' or 'z'
* @param {number} index the index of the slice
* @returns {Object} an object containing all the usefull information on the geometry of the slice
*/
extractPerpendicularPlane(axis, RASIndex) {
let firstSpacing, secondSpacing, positionOffset, IJKIndex;
const axisInIJK = new Vector3(), firstDirection = new Vector3(), secondDirection = new Vector3(), planeMatrix = new Matrix4().identity(), volume = this;
const dimensions = new Vector3(this.xLength, this.yLength, this.zLength);
switch (axis) {
case "x":
axisInIJK.set(1, 0, 0);
firstDirection.set(0, 0, -1);
secondDirection.set(0, -1, 0);
firstSpacing = this.spacing[this.axisOrder.indexOf("z")];
secondSpacing = this.spacing[this.axisOrder.indexOf("y")];
IJKIndex = new Vector3(RASIndex, 0, 0);
planeMatrix.multiply(new Matrix4().makeRotationY(Math.PI / 2));
positionOffset = (volume.RASDimensions[0] - 1) / 2;
planeMatrix.setPosition(new Vector3(RASIndex - positionOffset, 0, 0));
break;
case "y":
axisInIJK.set(0, 1, 0);
firstDirection.set(1, 0, 0);
secondDirection.set(0, 0, 1);
firstSpacing = this.spacing[this.axisOrder.indexOf("x")];
secondSpacing = this.spacing[this.axisOrder.indexOf("z")];
IJKIndex = new Vector3(0, RASIndex, 0);
planeMatrix.multiply(new Matrix4().makeRotationX(-Math.PI / 2));
positionOffset = (volume.RASDimensions[1] - 1) / 2;
planeMatrix.setPosition(new Vector3(0, RASIndex - positionOffset, 0));
break;
default:
axisInIJK.set(0, 0, 1);
firstDirection.set(1, 0, 0);
secondDirection.set(0, -1, 0);
firstSpacing = this.spacing[this.axisOrder.indexOf("x")];
secondSpacing = this.spacing[this.axisOrder.indexOf("y")];
IJKIndex = new Vector3(0, 0, RASIndex);
positionOffset = (volume.RASDimensions[2] - 1) / 2;
planeMatrix.setPosition(new Vector3(0, 0, RASIndex - positionOffset));
break;
}
let iLength, jLength;
if (!this.segmentation) {
firstDirection.applyMatrix4(volume.inverseMatrix).normalize();
secondDirection.applyMatrix4(volume.inverseMatrix).normalize();
axisInIJK.applyMatrix4(volume.inverseMatrix).normalize();
}
firstDirection.arglet = "i";
secondDirection.arglet = "j";
iLength = Math.floor(Math.abs(firstDirection.dot(dimensions)));
jLength = Math.floor(Math.abs(secondDirection.dot(dimensions)));
const planeWidth = Math.abs(iLength * firstSpacing);
const planeHeight = Math.abs(jLength * secondSpacing);
IJKIndex = Math.abs(Math.round(IJKIndex.applyMatrix4(volume.inverseMatrix).dot(axisInIJK)));
const base = [
new Vector3(1, 0, 0),
new Vector3(0, 1, 0),
new Vector3(0, 0, 1)
];
const iDirection = [
firstDirection,
secondDirection,
axisInIJK
].find(function(x) {
return Math.abs(x.dot(base[0])) > .9;
});
const jDirection = [
firstDirection,
secondDirection,
axisInIJK
].find(function(x) {
return Math.abs(x.dot(base[1])) > .9;
});
const kDirection = [
firstDirection,
secondDirection,
axisInIJK
].find(function(x) {
return Math.abs(x.dot(base[2])) > .9;
});
function sliceAccess(i, j) {
const si = iDirection === axisInIJK ? IJKIndex : iDirection.arglet === "i" ? i : j;
const sj = jDirection === axisInIJK ? IJKIndex : jDirection.arglet === "i" ? i : j;
const sk = kDirection === axisInIJK ? IJKIndex : kDirection.arglet === "i" ? i : j;
const accessI = iDirection.dot(base[0]) > 0 ? si : volume.xLength - 1 - si;
const accessJ = jDirection.dot(base[1]) > 0 ? sj : volume.yLength - 1 - sj;
const accessK = kDirection.dot(base[2]) > 0 ? sk : volume.zLength - 1 - sk;
return volume.access(accessI, accessJ, accessK);
}
return {
iLength,
jLength,
sliceAccess,
matrix: planeMatrix,
planeWidth,
planeHeight
};
}
/**
* @member {Function} extractSlice Returns a slice corresponding to the given axis and index
* The coordinate are given in the Right Anterior Superior coordinate format
* @memberof Volume
* @param {string} axis the normal axis to the slice 'x' 'y' or 'z'
* @param {number} index the index of the slice
* @returns {VolumeSlice} the extracted slice
*/
extractSlice(axis, index) {
const slice = new VolumeSlice(this, index, axis);
this.sliceList.push(slice);
return slice;
}
/**
* @member {Function} repaintAllSlices Call repaint on all the slices extracted from this volume
* @see VolumeSlice.repaint
* @memberof Volume
* @returns {Volume} this
*/
repaintAllSlices() {
this.sliceList.forEach(function(slice) {
slice.repaint();
});
return this;
}
/**
* @member {Function} computeMinMax Compute the minimum and the maximum of the data in the volume
* @memberof Volume
* @returns {Array} [min,max]
*/
computeMinMax() {
let min = Infinity;
let max = -Infinity;
const datasize = this.data.length;
let i = 0;
for (i = 0; i < datasize; i++) if (!isNaN(this.data[i])) {
const value = this.data[i];
min = Math.min(min, value);
max = Math.max(max, value);
}
this.min = min;
this.max = max;
return [min, max];
}
};
//#endregion
//#region node_modules/potpack/index.mjs
function potpack(boxes) {
let area = 0;
let maxWidth = 0;
for (const box of boxes) {
area += box.w * box.h;
maxWidth = Math.max(maxWidth, box.w);
}
boxes.sort((a, b) => b.h - a.h);
const spaces = [{
x: 0,
y: 0,
w: Math.max(Math.ceil(Math.sqrt(area / .95)), maxWidth),
h: Infinity
}];
let width = 0;
let height = 0;
for (const box of boxes) for (let i = spaces.length - 1; i >= 0; i--) {
const space = spaces[i];
if (box.w > space.w || box.h > space.h) continue;
box.x = space.x;
box.y = space.y;
height = Math.max(height, box.y + box.h);
width = Math.max(width, box.x + box.w);
if (box.w === space.w && box.h === space.h) {
const last = spaces.pop();
if (i < spaces.length) spaces[i] = last;
} else if (box.h === space.h) {
space.x += box.w;
space.w -= box.w;
} else if (box.w === space.w) {
space.y += box.h;
space.h -= box.h;
} else {
spaces.push({
x: space.x + box.w,
y: space.y,
w: space.w - box.w,
h: box.h
});
space.y += box.h;
space.h -= box.h;
}
break;
}
return {
w: width,
h: height,
fill: area / (width * height) || 0
};
}
//#endregion
//#region node_modules/three-stdlib/_polyfill/constants.js
var version = /* @__PURE__ */ (() => parseInt("184".replace(/\D+/g, "")))();
//#endregion
//#region node_modules/three-stdlib/_polyfill/uv1.js
var UV1 = version >= 125 ? "uv1" : "uv2";
//#endregion
//#region node_modules/three-stdlib/misc/ProgressiveLightmap.js
var ProgressiveLightMap = class {
constructor(renderer, res = 1024) {
this.renderer = renderer;
this.res = res;
this.lightMapContainers = [];
this.compiled = false;
this.scene = new Scene();
this.scene.background = null;
this.tinyTarget = new WebGLRenderTarget(1, 1);
this.buffer1Active = false;
this.firstUpdate = true;
this.warned = false;
const format = /(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent) ? alfFloatType : FloatType;
this.progressiveLightMap1 = new WebGLRenderTarget(this.res, this.res, { type: format });
this.progressiveLightMap2 = new WebGLRenderTarget(this.res, this.res, { type: format });
this.uvMat = new MeshPhongMaterial();
this.uvMat.uniforms = {};
this.uvMat.onBeforeCompile = (shader) => {
shader.vertexShader = "#define USE_LIGHTMAP\n" + shader.vertexShader.slice(0, -1) + ` gl_Position = vec4((${UV1} - 0.5) * 2.0, 1.0, 1.0); }`;
const bodyStart = shader.fragmentShader.indexOf("void main() {");
shader.fragmentShader = `varying vec2 v${UV1 === "uv1" ? UV1 : "Uv2"};
` + shader.fragmentShader.slice(0, bodyStart) + " uniform sampler2D previousShadowMap;\n uniform float averagingWindow;\n" + shader.fragmentShader.slice(bodyStart - 1, -1) + `
vec3 texelOld = texture2D(previousShadowMap, v${UV1 === "uv1" ? UV1 : "Uv2"}).rgb;
gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/averagingWindow);
}`;
shader.uniforms.previousShadowMap = { value: this.progressiveLightMap1.texture };
shader.uniforms.averagingWindow = { value: 100 };
this.uvMat.uniforms = shader.uniforms;
this.uvMat.userData.shader = shader;
this.compiled = true;
};
}
/**
* Sets these objects' materials' lightmaps and modifies their uv1's.
* @param {Object3D} objects An array of objects and lights to set up your lightmap.
*/
addObjectsToLightMap(objects) {
this.uv_boxes = [];
const padding = 3 / this.res;
for (let ob = 0; ob < objects.length; ob++) {
const object = objects[ob];
if (object.isLight) {
this.scene.attach(object);
continue;
}
if (!object.geometry.hasAttribute("uv")) {
console.warn("All lightmap objects need UVs!");
continue;
}
if (this.blurringPlane == null) this._initializeBlurPlane(this.res, this.progressiveLightMap1);
object.material.lightMap = this.progressiveLightMap2.texture;
object.material.dithering = true;
object.castShadow = true;
object.receiveShadow = true;
object.renderOrder = 1e3 + ob;
this.uv_boxes.push({
w: 1 + padding * 2,
h: 1 + padding * 2,
index: ob
});
this.lightMapContainers.push({
basicMat: object.material,
object
});
this.compiled = false;
}
const dimensions = potpack(this.uv_boxes);
this.uv_boxes.forEach((box) => {
const uv1 = objects[box.index].geometry.getAttribute("uv").clone();
for (let i = 0; i < uv1.array.length; i += uv1.itemSize) {
uv1.array[i] = (uv1.array[i] + box.x + padding) / dimensions.w;
uv1.array[i + 1] = (uv1.array[i + 1] + box.y + padding) / dimensions.h;
}
objects[box.index].geometry.setAttribute(UV1, uv1);
objects[box.index].geometry.getAttribute(UV1).needsUpdate = true;
});
}
/**
* This function renders each mesh one at a time into their respective surface maps
* @param {Camera} camera Standard Rendering Camera
* @param {number} blendWindow When >1, samples will accumulate over time.
* @param {boolean} blurEdges Whether to fix UV Edges via blurring
*/
update(camera, blendWindow = 100, blurEdges = true) {
if (this.blurringPlane == null) return;
const oldTarget = this.renderer.getRenderTarget();
this.blurringPlane.visible = blurEdges;
for (let l = 0; l < this.lightMapContainers.length; l++) {
this.lightMapContainers[l].object.oldScene = this.lightMapContainers[l].object.parent;
this.scene.attach(this.lightMapContainers[l].object);
}
if (this.firstUpdate) {
this.renderer.setRenderTarget(this.tinyTarget);
this.renderer.render(this.scene, camera);
this.firstUpdate = false;
}
for (let l = 0; l < this.lightMapContainers.length; l++) {
this.uvMat.uniforms.averagingWindow = { value: blendWindow };
this.lightMapContainers[l].object.material = this.uvMat;
this.lightMapContainers[l].object.oldFrustumCulled = this.lightMapContainers[l].object.frustumCulled;
this.lightMapContainers[l].object.frustumCulled = false;
}
const activeMap = this.buffer1Active ? this.progressiveLightMap1 : this.progressiveLightMap2;
const inactiveMap = this.buffer1Active ? this.progressiveLightMap2 : this.progressiveLightMap1;
this.renderer.setRenderTarget(activeMap);
this.uvMat.uniforms.previousShadowMap = { value: inactiveMap.texture };
this.blurringPlane.material.uniforms.previousShadowMap = { value: inactiveMap.texture };
this.buffer1Active = !this.buffer1Active;
this.renderer.render(this.scene, camera);
for (let l = 0; l < this.lightMapContainers.length; l++) {
this.lightMapContainers[l].object.frustumCulled = this.lightMapContainers[l].object.oldFrustumCulled;
this.lightMapContainers[l].object.material = this.lightMapContainers[l].basicMat;
this.lightMapContainers[l].object.oldScene.attach(this.lightMapContainers[l].object);
}
this.renderer.setRenderTarget(oldTarget);
}
/** DEBUG
* Draw the lightmap in the main scene. Call this after adding the objects to it.
* @param {boolean} visible Whether the debug plane should be visible
* @param {Vector3} position Where the debug plane should be drawn
*/
showDebugLightmap(visible, position = void 0) {
if (this.lightMapContainers.length == 0) {
if (!this.warned) {
console.warn("Call this after adding the objects!");
this.warned = true;
}
return;
}
if (this.labelMesh == null) {
this.labelMaterial = new MeshBasicMaterial({
map: this.progressiveLightMap1.texture,
side: 2
});
this.labelPlane = new PlaneGeometry(100, 100);
this.labelMesh = new Mesh(this.labelPlane, this.labelMaterial);
this.labelMesh.position.y = 250;
this.lightMapContainers[0].object.parent.add(this.labelMesh);
}
if (position != void 0) this.labelMesh.position.copy(position);
this.labelMesh.visible = visible;
}
/**
* INTERNAL Creates the Blurring Plane
* @param {number} res The square resolution of this object's lightMap.
* @param {WebGLRenderTexture} lightMap The lightmap to initialize the plane with.
*/
_initializeBlurPlane(res, lightMap = null) {
const blurMaterial = new MeshBasicMaterial();
blurMaterial.uniforms = {
previousShadowMap: { value: null },
pixelOffset: { value: 1 / res },
polygonOffset: true,
polygonOffsetFactor: -1,
polygonOffsetUnits: 3
};
blurMaterial.onBeforeCompile = (shader) => {
shader.vertexShader = "#define USE_UV\n" + shader.vertexShader.slice(0, -1) + " gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";
const bodyStart = shader.fragmentShader.indexOf("void main() {");
shader.fragmentShader = "#define USE_UV\n" + shader.fragmentShader.slice(0, bodyStart) + " uniform sampler2D previousShadowMap;\n uniform float pixelOffset;\n" + shader.fragmentShader.slice(bodyStart - 1, -1) + ` gl_FragColor.rgb = (
texture2D(previousShadowMap, vUv + vec2( pixelOffset, 0.0 )).rgb +
texture2D(previousShadowMap, vUv + vec2( 0.0 , pixelOffset)).rgb +
texture2D(previousShadowMap, vUv + vec2( 0.0 , -pixelOffset)).rgb +
texture2D(previousShadowMap, vUv + vec2(-pixelOffset, 0.0 )).rgb +
texture2D(previousShadowMap, vUv + vec2( pixelOffset, pixelOffset)).rgb +
texture2D(previousShadowMap, vUv + vec2(-pixelOffset, pixelOffset)).rgb +
texture2D(previousShadowMap, vUv + vec2( pixelOffset, -pixelOffset)).rgb +
texture2D(previousShadowMap, vUv + vec2(-pixelOffset, -pixelOffset)).rgb)/8.0;
}`;
shader.uniforms.previousShadowMap = { value: lightMap.texture };
shader.uniforms.pixelOffset = { value: .5 / res };
blurMaterial.uniforms = shader.uniforms;
blurMaterial.userData.shader = shader;
this.compiled = true;
};
this.blurringPlane = new Mesh(new PlaneGeometry(1, 1), blurMaterial);
this.blurringPlane.name = "Blurring Plane";
this.blurringPlane.frustumCulled = false;
this.blurringPlane.renderOrder = 0;
this.blurringPlane.material.depthWrite = false;
this.scene.add(this.blurringPlane);
}
};
//#endregion
//#region node_modules/three-stdlib/renderers/CSS2DRenderer.js
var CSS2DObject = class extends Object3D {
constructor(element = document.createElement("div")) {
super();
this.isCSS2DObject = true;
this.element = element;
this.element.style.position = "absolute";
this.element.style.userSelect = "none";
this.element.setAttribute("draggable", false);
this.center = new Vector2(.5, .5);
this.addEventListener("removed", function() {
this.traverse(function(object) {
if (object.element instanceof Element && object.element.parentNode !== null) object.element.parentNode.removeChild(object.element);
});
});
}
copy(source, recursive) {
super.copy(source, recursive);
this.element = source.element.cloneNode(true);
this.center = source.center;
return this;
}
};
var _vector$4 = /* @__PURE__ */ new Vector3();
var _viewMatrix = /* @__PURE__ */ new Matrix4();
var _viewProjectionMatrix = /* @__PURE__ */ new Matrix4();
var _a$1 = /* @__PURE__ */ new Vector3();
var _b$1 = /* @__PURE__ */ new Vector3();
var CSS2DRenderer = class {
constructor(parameters = {}) {
const _this = this;
let _width, _height;
let _widthHalf, _heightHalf;
const cache = { objects: /* @__PURE__ */ new WeakMap() };
const domElement = parameters.element !== void 0 ? parameters.element : document.createElement("div");
domElement.style.overflow = "hidden";
this.domElement = domElement;
this.getSize = function() {
return {
width: _width,
height: _height
};
};
this.render = function(scene, camera) {
if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
if (camera.parent === null && camera.matrixWorldAutoUpdate === true) camera.updateMatrixWorld();
_viewMatrix.copy(camera.matrixWorldInverse);
_viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, _viewMatrix);
renderObject(scene, scene, camera);
zOrder(scene);
};
this.setSize = function(width, height) {
_width = width;
_height = height;
_widthHalf = _width / 2;
_heightHalf = _height / 2;
domElement.style.width = width + "px";
domElement.style.height = height + "px";
};
function renderObject(object, scene, camera) {
if (object.isCSS2DObject) {
_vector$4.setFromMatrixPosition(object.matrixWorld);
_vector$4.applyMatrix4(_viewProjectionMatrix);
const visible = object.visible === true && _vector$4.z >= -1 && _vector$4.z <= 1 && object.layers.test(camera.layers) === true;
object.element.style.display = visible === true ? "" : "none";
if (visible === true) {
object.onBeforeRender(_this, scene, camera);
const element = object.element;
element.style.transform = "translate(" + -100 * object.center.x + "%," + -100 * object.center.y + "%)translate(" + (_vector$4.x * _widthHalf + _widthHalf) + "px," + (-_vector$4.y * _heightHalf + _heightHalf) + "px)";
if (element.parentNode !== domElement) domElement.appendChild(element);
object.onAfterRender(_this, scene, camera);
}
const objectData = { distanceToCameraSquared: getDistanceToSquared(camera, object) };
cache.objects.set(object, objectData);
}
for (let i = 0, l = object.children.length; i < l; i++) renderObject(object.children[i], scene, camera);
}
function getDistanceToSquared(object1, object2) {
_a$1.setFromMatrixPosition(object1.matrixWorld);
_b$1.setFromMatrixPosition(object2.matrixWorld);
return _a$1.distanceToSquared(_b$1);
}
function filterAndFlatten(scene) {
const result = [];
scene.traverse(function(object) {
if (object.isCSS2DObject) result.push(object);
});
return result;
}
function zOrder(scene) {
const sorted = filterAndFlatten(scene).sort(function(a, b) {
if (a.renderOrder !== b.renderOrder) return b.renderOrder - a.renderOrder;
return cache.objects.get(a).distanceToCameraSquared - cache.objects.get(b).distanceToCameraSquared;
});
const zMax = sorted.length;
for (let i = 0, l = sorted.length; i < l; i++) sorted[i].element.style.zIndex = zMax - i;
}
}
};
//#endregion
//#region node_modules/three-stdlib/renderers/CSS3DRenderer.js
var _position$1 = /* @__PURE__ */ new Vector3();
var _quaternion$1 = /* @__PURE__ */ new Quaternion();
var _scale$1 = /* @__PURE__ */ new Vector3();
var CSS3DObject = class extends Object3D {
constructor(element = document.createElement("div")) {
super();
this.isCSS3DObject = true;
this.element = element;
this.element.style.position = "absolute";
this.element.style.pointerEvents = "auto";
this.element.style.userSelect = "none";
this.element.setAttribute("draggable", false);
this.addEventListener("removed", function() {
this.traverse(function(object) {
if (object.element instanceof Element && object.element.parentNode !== null) object.element.parentNode.removeChild(object.element);
});
});
}
copy(source, recursive) {
super.copy(source, recursive);
this.element = source.element.cloneNode(true);
return this;
}
};
var CSS3DSprite = class extends CSS3DObject {
constructor(element) {
super(element);
this.isCSS3DSprite = true;
this.rotation2D = 0;
}
copy(source, recursive) {
super.copy(source, recursive);
this.rotation2D = source.rotation2D;
return this;
}
};
var _matrix$2 = /* @__PURE__ */ new Matrix4();
var _matrix2 = /* @__PURE__ */ new Matrix4();
var CSS3DRenderer = class {
constructor(parameters = {}) {
const _this = this;
let _width, _height;
let _widthHalf, _heightHalf;
const cache = {
camera: { style: "" },
objects: /* @__PURE__ */ new WeakMap()
};
const domElement = parameters.element !== void 0 ? parameters.element : document.createElement("div");
domElement.style.overflow = "hidden";
this.domElement = domElement;
const viewElement = document.createElement("div");
viewElement.style.transformOrigin = "0 0";
viewElement.style.pointerEvents = "none";
domElement.appendChild(viewElement);
const cameraElement = document.createElement("div");
cameraElement.style.transformStyle = "preserve-3d";
viewElement.appendChild(cameraElement);
this.getSize = function() {
return {
width: _width,
height: _height
};
};
this.render = function(scene, camera) {
const fov = camera.projectionMatrix.elements[5] * _heightHalf;
if (camera.view && camera.view.enabled) {
viewElement.style.transform = `translate( ${-camera.view.offsetX * (_width / camera.view.width)}px, ${-camera.view.offsetY * (_height / camera.view.height)}px )`;
viewElement.style.transform += `scale( ${camera.view.fullWidth / camera.view.width}, ${camera.view.fullHeight / camera.view.height} )`;
} else viewElement.style.transform = "";
if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
if (camera.parent === null && camera.matrixWorldAutoUpdate === true) camera.updateMatrixWorld();
let tx, ty;
if (camera.isOrthographicCamera) {
tx = -(camera.right + camera.left) / 2;
ty = (camera.top + camera.bottom) / 2;
}
const scaleByViewOffset = camera.view && camera.view.enabled ? camera.view.height / camera.view.fullHeight : 1;
const cameraCSSMatrix = camera.isOrthographicCamera ? `scale( ${scaleByViewOffset} )scale(` + fov + ")translate(" + epsilon(tx) + "px," + epsilon(ty) + "px)" + getCameraCSSMatrix(camera.matrixWorldInverse) : `scale( ${scaleByViewOffset} )translateZ(` + fov + "px)" + getCameraCSSMatrix(camera.matrixWorldInverse);
const style = (camera.isPerspectiveCamera ? "perspective(" + fov + "px) " : "") + cameraCSSMatrix + "translate(" + _widthHalf + "px," + _heightHalf + "px)";
if (cache.camera.style !== style) {
cameraElement.style.transform = style;
cache.camera.style = style;
}
renderObject(scene, scene, camera);
};
this.setSize = function(width, height) {
_width = width;
_height = height;
_widthHalf = _width / 2;
_heightHalf = _height / 2;
domElement.style.width = width + "px";
domElement.style.height = height + "px";
viewElement.style.width = width + "px";
viewElement.style.height = height + "px";
cameraElement.style.width = width + "px";
cameraElement.style.height = height + "px";
};
function epsilon(value) {
return Math.abs(value) < 1e-10 ? 0 : value;
}
function getCameraCSSMatrix(matrix) {
const elements = matrix.elements;
return "matrix3d(" + epsilon(elements[0]) + "," + epsilon(-elements[1]) + "," + epsilon(elements[2]) + "," + epsilon(elements[3]) + "," + epsilon(elements[4]) + "," + epsilon(-elements[5]) + "," + epsilon(elements[6]) + "," + epsilon(elements[7]) + "," + epsilon(elements[8]) + "," + epsilon(-elements[9]) + "," + epsilon(elements[10]) + "," + epsilon(elements[11]) + "," + epsilon(elements[12]) + "," + epsilon(-elements[13]) + "," + epsilon(elements[14]) + "," + epsilon(elements[15]) + ")";
}
function getObjectCSSMatrix(matrix) {
const elements = matrix.elements;
return "translate(-50%,-50%)" + ("matrix3d(" + epsilon(elements[0]) + "," + epsilon(elements[1]) + "," + epsilon(elements[2]) + "," + epsilon(elements[3]) + "," + epsilon(-elements[4]) + "," + epsilon(-elements[5]) + "," + epsilon(-elements[6]) + "," + epsilon(-elements[7]) + "," + epsilon(elements[8]) + "," + epsilon(elements[9]) + "," + epsilon(elements[10]) + "," + epsilon(elements[11]) + "," + epsilon(elements[12]) + "," + epsilon(elements[13]) + "," + epsilon(elements[14]) + "," + epsilon(elements[15]) + ")");
}
function renderObject(object, scene, camera, cameraCSSMatrix) {
if (object.isCSS3DObject) {
const visible = object.visible === true && object.layers.test(camera.layers) === true;
object.element.style.display = visible === true ? "" : "none";
if (visible === true) {
object.onBeforeRender(_this, scene, camera);
let style;
if (object.isCSS3DSprite) {
_matrix$2.copy(camera.matrixWorldInverse);
_matrix$2.transpose();
if (object.rotation2D !== 0) _matrix$2.multiply(_matrix2.makeRotationZ(object.rotation2D));
object.matrixWorld.decompose(_position$1, _quaternion$1, _scale$1);
_matrix$2.setPosition(_position$1);
_matrix$2.scale(_scale$1);
_matrix$2.elements[3] = 0;
_matrix$2.elements[7] = 0;
_matrix$2.elements[11] = 0;
_matrix$2.elements[15] = 1;
style = getObjectCSSMatrix(_matrix$2);
} else style = getObjectCSSMatrix(object.matrixWorld);
const element = object.element;
const cachedObject = cache.objects.get(object);
if (cachedObject === void 0 || cachedObject.style !== style) {
element.style.transform = style;
const objectData = { style };
cache.objects.set(object, objectData);
}
if (element.parentNode !== cameraElement) cameraElement.appendChild(element);
object.onAfterRender(_this, scene, camera);
}
}
for (let i = 0, l = object.children.length; i < l; i++) renderObject(object.children[i], scene, camera);
}
}
};
//#endregion
//#region node_modules/three-stdlib/renderers/Projector.js
var RenderableObject = class {
constructor() {
this.id = 0;
this.object = null;
this.z = 0;
this.renderOrder = 0;
}
};
var RenderableFace = class {
constructor() {
this.id = 0;
this.v1 = new RenderableVertex();
this.v2 = new RenderableVertex();
this.v3 = new RenderableVertex();
this.normalModel = new Vector3();
this.vertexNormalsModel = [
new Vector3(),
new Vector3(),
new Vector3()
];
this.vertexNormalsLength = 0;
this.color = new Color();
this.material = null;
this.uvs = [
new Vector2(),
new Vector2(),
new Vector2()
];
this.z = 0;
this.renderOrder = 0;
}
};
var RenderableVertex = class {
constructor() {
this.position = new Vector3();
this.positionWorld = new Vector3();
this.positionScreen = new Vector4();
this.visible = true;
}
copy(vertex) {
this.positionWorld.copy(vertex.positionWorld);
this.positionScreen.copy(vertex.positionScreen);
}
};
var RenderableLine = class {
constructor() {
this.id = 0;
this.v1 = new RenderableVertex();
this.v2 = new RenderableVertex();
this.vertexColors = [new Color(), new Color()];
this.material = null;
this.z = 0;
this.renderOrder = 0;
}
};
var RenderableSprite = class {
constructor() {
this.id = 0;
this.object = null;
this.x = 0;
this.y = 0;
this.z = 0;
this.rotation = 0;
this.scale = new Vector2();
this.material = null;
this.renderOrder = 0;
}
};
var Projector = class {
constructor() {
let _object, _objectCount, _objectPoolLength = 0, _vertex, _vertexCount, _vertexPoolLength = 0, _face, _faceCount, _facePoolLength = 0, _line, _lineCount, _linePoolLength = 0, _sprite, _spriteCount, _spritePoolLength = 0, _modelMatrix;
const _renderData = {
objects: [],
lights: [],
elements: []
}, _vector3 = new Vector3(), _vector4 = new Vector4(), _clipBox = new Box3(new Vector3(-1, -1, -1), new Vector3(1, 1, 1)), _boundingBox = new Box3(), _points3 = new Array(3), _viewMatrix = new Matrix4(), _viewProjectionMatrix = new Matrix4(), _modelViewProjectionMatrix = new Matrix4(), _frustum = new Frustum(), _objectPool = [], _vertexPool = [], _facePool = [], _linePool = [], _spritePool = [];
function RenderList() {
const normals = [];
const colors = [];
const uvs = [];
let object = null;
const normalMatrix = new Matrix3();
function setObject(value) {
object = value;
normalMatrix.getNormalMatrix(object.matrixWorld);
normals.length = 0;
colors.length = 0;
uvs.length = 0;
}
function projectVertex(vertex) {
const position = vertex.position;
const positionWorld = vertex.positionWorld;
const positionScreen = vertex.positionScreen;
positionWorld.copy(position).applyMatrix4(_modelMatrix);
positionScreen.copy(positionWorld).applyMatrix4(_viewProjectionMatrix);
const invW = 1 / positionScreen.w;
positionScreen.x *= invW;
positionScreen.y *= invW;
positionScreen.z *= invW;
vertex.visible = positionScreen.x >= -1 && positionScreen.x <= 1 && positionScreen.y >= -1 && positionScreen.y <= 1 && positionScreen.z >= -1 && positionScreen.z <= 1;
}
function pushVertex(x, y, z) {
_vertex = getNextVertexInPool();
_vertex.position.set(x, y, z);
projectVertex(_vertex);
}
function pushNormal(x, y, z) {
normals.push(x, y, z);
}
function pushColor(r, g, b) {
colors.push(r, g, b);
}
function pushUv(x, y) {
uvs.push(x, y);
}
function checkTriangleVisibility(v1, v2, v3) {
if (v1.visible === true || v2.visible === true || v3.visible === true) return true;
_points3[0] = v1.positionScreen;
_points3[1] = v2.positionScreen;
_points3[2] = v3.positionScreen;
return _clipBox.intersectsBox(_boundingBox.setFromPoints(_points3));
}
function checkBackfaceCulling(v1, v2, v3) {
return (v3.positionScreen.x - v1.positionScreen.x) * (v2.positionScreen.y - v1.positionScreen.y) - (v3.positionScreen.y - v1.positionScreen.y) * (v2.positionScreen.x - v1.positionScreen.x) < 0;
}
function pushLine(a, b) {
const v1 = _vertexPool[a];
const v2 = _vertexPool[b];
v1.positionScreen.copy(v1.position).applyMatrix4(_modelViewProjectionMatrix);
v2.positionScreen.copy(v2.position).applyMatrix4(_modelViewProjectionMatrix);
if (clipLine(v1.positionScreen, v2.positionScreen) === true) {
v1.positionScreen.multiplyScalar(1 / v1.positionScreen.w);
v2.positionScreen.multiplyScalar(1 / v2.positionScreen.w);
_line = getNextLineInPool();
_line.id = object.id;
_line.v1.copy(v1);
_line.v2.copy(v2);
_line.z = Math.max(v1.positionScreen.z, v2.positionScreen.z);
_line.renderOrder = object.renderOrder;
_line.material = object.material;
if (object.material.vertexColors) {
_line.vertexColors[0].fromArray(colors, a * 3);
_line.vertexColors[1].fromArray(colors, b * 3);
}
_renderData.elements.push(_line);
}
}
function pushTriangle(a, b, c, material) {
const v1 = _vertexPool[a];
const v2 = _vertexPool[b];
const v3 = _vertexPool[c];
if (checkTriangleVisibility(v1, v2, v3) === false) return;
if (material.side === 2 || checkBackfaceCulling(v1, v2, v3) === true) {
_face = getNextFaceInPool();
_face.id = object.id;
_face.v1.copy(v1);
_face.v2.copy(v2);
_face.v3.copy(v3);
_face.z = (v1.positionScreen.z + v2.positionScreen.z + v3.positionScreen.z) / 3;
_face.renderOrder = object.renderOrder;
_vector3.subVectors(v3.position, v2.position);
_vector4.subVectors(v1.position, v2.position);
_vector3.cross(_vector4);
_face.normalModel.copy(_vector3);
_face.normalModel.applyMatrix3(normalMatrix).normalize();
for (let i = 0; i < 3; i++) {
const normal = _face.vertexNormalsModel[i];
normal.fromArray(normals, arguments[i] * 3);
normal.applyMatrix3(normalMatrix).normalize();
_face.uvs[i].fromArray(uvs, arguments[i] * 2);
}
_face.vertexNormalsLength = 3;
_face.material = material;
if (material.vertexColors) _face.color.fromArray(colors, a * 3);
_renderData.elements.push(_face);
}
}
return {
setObject,
projectVertex,
checkTriangleVisibility,
checkBackfaceCulling,
pushVertex,
pushNormal,
pushColor,
pushUv,
pushLine,
pushTriangle
};
}
const renderList = new RenderList();
function projectObject(object) {
if (object.visible === false) return;
if (object.isLight) _renderData.lights.push(object);
else if (object.isMesh || object.isLine || object.isPoints) {
if (object.material.visible === false) return;
if (object.frustumCulled === true && _frustum.intersectsObject(object) === false) return;
addObject(object);
} else if (object.isSprite) {
if (object.material.visible === false) return;
if (object.frustumCulled === true && _frustum.intersectsSprite(object) === false) return;
addObject(object);
}
const children = object.children;
for (let i = 0, l = children.length; i < l; i++) projectObject(children[i]);
}
function addObject(object) {
_object = getNextObjectInPool();
_object.id = object.id;
_object.object = object;
_vector3.setFromMatrixPosition(object.matrixWorld);
_vector3.applyMatrix4(_viewProjectionMatrix);
_object.z = _vector3.z;
_object.renderOrder = object.renderOrder;
_renderData.objects.push(_object);
}
this.projectScene = function(scene, camera, sortObjects, sortElements) {
_faceCount = 0;
_lineCount = 0;
_spriteCount = 0;
_renderData.elements.length = 0;
if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
if (camera.parent === null && camera.matrixWorldAutoUpdate === true) camera.updateMatrixWorld();
_viewMatrix.copy(camera.matrixWorldInverse);
_viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, _viewMatrix);
_frustum.setFromProjectionMatrix(_viewProjectionMatrix);
_objectCount = 0;
_renderData.objects.length = 0;
_renderData.lights.length = 0;
projectObject(scene);
if (sortObjects === true) _renderData.objects.sort(painterSort);
const objects = _renderData.objects;
for (let o = 0, ol = objects.length; o < ol; o++) {
const object = objects[o].object;
const geometry = object.geometry;
renderList.setObject(object);
_modelMatrix = object.matrixWorld;
_vertexCount = 0;
if (object.isMesh) {
let material = object.material;
const isMultiMaterial = Array.isArray(material);
const attributes = geometry.attributes;
const groups = geometry.groups;
if (attributes.position === void 0) continue;
const positions = attributes.position.array;
for (let i = 0, l = positions.length; i < l; i += 3) {
let x = positions[i];
let y = positions[i + 1];
let z = positions[i + 2];
const morphTargets = geometry.morphAttributes.position;
if (morphTargets !== void 0) {
const morphTargetsRelative = geometry.morphTargetsRelative;
const morphInfluences = object.morphTargetInfluences;
for (let t = 0, tl = morphTargets.length; t < tl; t++) {
const influence = morphInfluences[t];
if (influence === 0) continue;
const target = morphTargets[t];
if (morphTargetsRelative) {
x += target.getX(i / 3) * influence;
y += target.getY(i / 3) * influence;
z += target.getZ(i / 3) * influence;
} else {
x += (target.getX(i / 3) - positions[i]) * influence;
y += (target.getY(i / 3) - positions[i + 1]) * influence;
z += (target.getZ(i / 3) - positions[i + 2]) * influence;
}
}
}
renderList.pushVertex(x, y, z);
}
if (attributes.normal !== void 0) {
const normals = attributes.normal.array;
for (let i = 0, l = normals.length; i < l; i += 3) renderList.pushNormal(normals[i], normals[i + 1], normals[i + 2]);
}
if (attributes.color !== void 0) {
const colors = attributes.color.array;
for (let i = 0, l = colors.length; i < l; i += 3) renderList.pushColor(colors[i], colors[i + 1], colors[i + 2]);
}
if (attributes.uv !== void 0) {
const uvs = attributes.uv.array;
for (let i = 0, l = uvs.length; i < l; i += 2) renderList.pushUv(uvs[i], uvs[i + 1]);
}
if (geometry.index !== null) {
const indices = geometry.index.array;
if (groups.length > 0) for (let g = 0; g < groups.length; g++) {
const group = groups[g];
material = isMultiMaterial === true ? object.material[group.materialIndex] : object.material;
if (material === void 0) continue;
for (let i = group.start, l = group.start + group.count; i < l; i += 3) renderList.pushTriangle(indices[i], indices[i + 1], indices[i + 2], material);
}
else for (let i = 0, l = indices.length; i < l; i += 3) renderList.pushTriangle(indices[i], indices[i + 1], indices[i + 2], material);
} else if (groups.length > 0) for (let g = 0; g < groups.length; g++) {
const group = groups[g];
material = isMultiMaterial === true ? object.material[group.materialIndex] : object.material;
if (material === void 0) continue;
for (let i = group.start, l = group.start + group.count; i < l; i += 3) renderList.pushTriangle(i, i + 1, i + 2, material);
}
else for (let i = 0, l = positions.length / 3; i < l; i += 3) renderList.pushTriangle(i, i + 1, i + 2, material);
} else if (object.isLine) {
_modelViewProjectionMatrix.multiplyMatrices(_viewProjectionMatrix, _modelMatrix);
const attributes = geometry.attributes;
if (attributes.position !== void 0) {
const positions = attributes.position.array;
for (let i = 0, l = positions.length; i < l; i += 3) renderList.pushVertex(positions[i], positions[i + 1], positions[i + 2]);
if (attributes.color !== void 0) {
const colors = attributes.color.array;
for (let i = 0, l = colors.length; i < l; i += 3) renderList.pushColor(colors[i], colors[i + 1], colors[i + 2]);
}
if (geometry.index !== null) {
const indices = geometry.index.array;
for (let i = 0, l = indices.length; i < l; i += 2) renderList.pushLine(indices[i], indices[i + 1]);
} else {
const step = object.isLineSegments ? 2 : 1;
for (let i = 0, l = positions.length / 3 - 1; i < l; i += step) renderList.pushLine(i, i + 1);
}
}
} else if (object.isPoints) {
_modelViewProjectionMatrix.multiplyMatrices(_viewProjectionMatrix, _modelMatrix);
const attributes = geometry.attributes;
if (attributes.position !== void 0) {
const positions = attributes.position.array;
for (let i = 0, l = positions.length; i < l; i += 3) {
_vector4.set(positions[i], positions[i + 1], positions[i + 2], 1);
_vector4.applyMatrix4(_modelViewProjectionMatrix);
pushPoint(_vector4, object, camera);
}
}
} else if (object.isSprite) {
object.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);
_vector4.set(_modelMatrix.elements[12], _modelMatrix.elements[13], _modelMatrix.elements[14], 1);
_vector4.applyMatrix4(_viewProjectionMatrix);
pushPoint(_vector4, object, camera);
}
}
if (sortElements === true) _renderData.elements.sort(painterSort);
return _renderData;
};
function pushPoint(_vector42, object, camera) {
const invW = 1 / _vector42.w;
_vector42.z *= invW;
if (_vector42.z >= -1 && _vector42.z <= 1) {
_sprite = getNextSpriteInPool();
_sprite.id = object.id;
_sprite.x = _vector42.x * invW;
_sprite.y = _vector42.y * invW;
_sprite.z = _vector42.z;
_sprite.renderOrder = object.renderOrder;
_sprite.object = object;
_sprite.rotation = object.rotation;
_sprite.scale.x = object.scale.x * Math.abs(_sprite.x - (_vector42.x + camera.projectionMatrix.elements[0]) / (_vector42.w + camera.projectionMatrix.elements[12]));
_sprite.scale.y = object.scale.y * Math.abs(_sprite.y - (_vector42.y + camera.projectionMatrix.elements[5]) / (_vector42.w + camera.projectionMatrix.elements[13]));
_sprite.material = object.material;
_renderData.elements.push(_sprite);
}
}
function getNextObjectInPool() {
if (_objectCount === _objectPoolLength) {
const object = new RenderableObject();
_objectPool.push(object);
_objectPoolLength++;
_objectCount++;
return object;
}
return _objectPool[_objectCount++];
}
function getNextVertexInPool() {
if (_vertexCount === _vertexPoolLength) {
const vertex = new RenderableVertex();
_vertexPool.push(vertex);
_vertexPoolLength++;
_vertexCount++;
return vertex;
}
return _vertexPool[_vertexCount++];
}
function getNextFaceInPool() {
if (_faceCount === _facePoolLength) {
const face = new RenderableFace();
_facePool.push(face);
_facePoolLength++;
_faceCount++;
return face;
}
return _facePool[_faceCount++];
}
function getNextLineInPool() {
if (_lineCount === _linePoolLength) {
const line = new RenderableLine();
_linePool.push(line);
_linePoolLength++;
_lineCount++;
return line;
}
return _linePool[_lineCount++];
}
function getNextSpriteInPool() {
if (_spriteCount === _spritePoolLength) {
const sprite = new RenderableSprite();
_spritePool.push(sprite);
_spritePoolLength++;
_spriteCount++;
return sprite;
}
return _spritePool[_spriteCount++];
}
function painterSort(a, b) {
if (a.renderOrder !== b.renderOrder) return a.renderOrder - b.renderOrder;
else if (a.z !== b.z) return b.z - a.z;
else if (a.id !== b.id) return a.id - b.id;
else return 0;
}
function clipLine(s1, s2) {
let alpha1 = 0, alpha2 = 1;
const bc1near = s1.z + s1.w, bc2near = s2.z + s2.w, bc1far = -s1.z + s1.w, bc2far = -s2.z + s2.w;
if (bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0) return true;
else if (bc1near < 0 && bc2near < 0 || bc1far < 0 && bc2far < 0) return false;
else {
if (bc1near < 0) alpha1 = Math.max(alpha1, bc1near / (bc1near - bc2near));
else if (bc2near < 0) alpha2 = Math.min(alpha2, bc1near / (bc1near - bc2near));
if (bc1far < 0) alpha1 = Math.max(alpha1, bc1far / (bc1far - bc2far));
else if (bc2far < 0) alpha2 = Math.min(alpha2, bc1far / (bc1far - bc2far));
if (alpha2 < alpha1) return false;
else {
s1.lerp(s2, alpha1);
s2.lerp(s1, 1 - alpha2);
return true;
}
}
}
}
};
//#endregion
//#region node_modules/three-stdlib/renderers/SVGRenderer.js
var SVGObject = class extends Object3D {
constructor(node) {
super();
this.isSVGObject = true;
this.node = node;
}
};
var SVGRenderer = class {
constructor() {
let _renderData, _elements, _lights, _svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf, _v1, _v2, _v3, _svgNode, _pathCount = 0, _precision = null, _quality = 1, _currentPath, _currentStyle;
const _this = this, _clipBox = new Box2(), _elemBox = new Box2(), _color = new Color(), _diffuseColor = new Color(), _ambientLight = new Color(), _directionalLights = new Color(), _pointLights = new Color(), _clearColor = new Color(), _vector3 = new Vector3(), _centroid = new Vector3(), _normal = new Vector3(), _normalViewMatrix = new Matrix3(), _viewMatrix = new Matrix4(), _viewProjectionMatrix = new Matrix4(), _svgPathPool = [], _projector = new Projector(), _svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
this.domElement = _svg;
this.autoClear = true;
this.sortObjects = true;
this.sortElements = true;
this.overdraw = .5;
this.info = { render: {
vertices: 0,
faces: 0
} };
this.setQuality = function(quality) {
switch (quality) {
case "high":
_quality = 1;
break;
case "low":
_quality = 0;
break;
}
};
this.setClearColor = function(color) {
_clearColor.set(color);
};
this.setPixelRatio = function() {};
this.setSize = function(width, height) {
_svgWidth = width;
_svgHeight = height;
_svgWidthHalf = _svgWidth / 2;
_svgHeightHalf = _svgHeight / 2;
_svg.setAttribute("viewBox", -_svgWidthHalf + " " + -_svgHeightHalf + " " + _svgWidth + " " + _svgHeight);
_svg.setAttribute("width", _svgWidth);
_svg.setAttribute("height", _svgHeight);
_clipBox.min.set(-_svgWidthHalf, -_svgHeightHalf);
_clipBox.max.set(_svgWidthHalf, _svgHeightHalf);
};
this.getSize = function() {
return {
width: _svgWidth,
height: _svgHeight
};
};
this.setPrecision = function(precision) {
_precision = precision;
};
function removeChildNodes() {
_pathCount = 0;
while (_svg.childNodes.length > 0) _svg.removeChild(_svg.childNodes[0]);
}
function convert(c) {
return _precision !== null ? c.toFixed(_precision) : c;
}
this.clear = function() {
removeChildNodes();
_svg.style.backgroundColor = _clearColor.getStyle();
};
this.render = function(scene, camera) {
if (camera instanceof Camera === false) {
console.error("THREE.SVGRenderer.render: camera is not an instance of Camera.");
return;
}
const background = scene.background;
if (background && background.isColor) {
removeChildNodes();
_svg.style.backgroundColor = background.getStyle();
} else if (this.autoClear === true) this.clear();
_this.info.render.vertices = 0;
_this.info.render.faces = 0;
_viewMatrix.copy(camera.matrixWorldInverse);
_viewProjectionMatrix.multiplyMatrices(camera.projectionMatrix, _viewMatrix);
_renderData = _projector.projectScene(scene, camera, this.sortObjects, this.sortElements);
_elements = _renderData.elements;
_lights = _renderData.lights;
_normalViewMatrix.getNormalMatrix(camera.matrixWorldInverse);
calculateLights(_lights);
_currentPath = "";
_currentStyle = "";
for (let e = 0, el = _elements.length; e < el; e++) {
const element = _elements[e];
const material = element.material;
if (material === void 0 || material.opacity === 0) continue;
_elemBox.makeEmpty();
if (element instanceof RenderableSprite) {
_v1 = element;
_v1.x *= _svgWidthHalf;
_v1.y *= -_svgHeightHalf;
renderSprite(_v1, element, material);
} else if (element instanceof RenderableLine) {
_v1 = element.v1;
_v2 = element.v2;
_v1.positionScreen.x *= _svgWidthHalf;
_v1.positionScreen.y *= -_svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf;
_v2.positionScreen.y *= -_svgHeightHalf;
_elemBox.setFromPoints([_v1.positionScreen, _v2.positionScreen]);
if (_clipBox.intersectsBox(_elemBox) === true) renderLine(_v1, _v2, material);
} else if (element instanceof RenderableFace) {
_v1 = element.v1;
_v2 = element.v2;
_v3 = element.v3;
if (_v1.positionScreen.z < -1 || _v1.positionScreen.z > 1) continue;
if (_v2.positionScreen.z < -1 || _v2.positionScreen.z > 1) continue;
if (_v3.positionScreen.z < -1 || _v3.positionScreen.z > 1) continue;
_v1.positionScreen.x *= _svgWidthHalf;
_v1.positionScreen.y *= -_svgHeightHalf;
_v2.positionScreen.x *= _svgWidthHalf;
_v2.positionScreen.y *= -_svgHeightHalf;
_v3.positionScreen.x *= _svgWidthHalf;
_v3.positionScreen.y *= -_svgHeightHalf;
if (this.overdraw > 0) {
expand(_v1.positionScreen, _v2.positionScreen, this.overdraw);
expand(_v2.positionScreen, _v3.positionScreen, this.overdraw);
expand(_v3.positionScreen, _v1.positionScreen, this.overdraw);
}
_elemBox.setFromPoints([
_v1.positionScreen,
_v2.positionScreen,
_v3.positionScreen
]);
if (_clipBox.intersectsBox(_elemBox) === true) renderFace3(_v1, _v2, _v3, element, material);
}
}
flushPath();
scene.traverseVisible(function(object) {
if (object.isSVGObject) {
_vector3.setFromMatrixPosition(object.matrixWorld);
_vector3.applyMatrix4(_viewProjectionMatrix);
if (_vector3.z < -1 || _vector3.z > 1) return;
const x = _vector3.x * _svgWidthHalf;
const y = -_vector3.y * _svgHeightHalf;
const node = object.node;
node.setAttribute("transform", "translate(" + x + "," + y + ")");
_svg.appendChild(node);
}
});
};
function calculateLights(lights) {
_ambientLight.setRGB(0, 0, 0);
_directionalLights.setRGB(0, 0, 0);
_pointLights.setRGB(0, 0, 0);
for (let l = 0, ll = lights.length; l < ll; l++) {
const light = lights[l];
const lightColor = light.color;
if (light.isAmbientLight) {
_ambientLight.r += lightColor.r;
_ambientLight.g += lightColor.g;
_ambientLight.b += lightColor.b;
} else if (light.isDirectionalLight) {
_directionalLights.r += lightColor.r;
_directionalLights.g += lightColor.g;
_directionalLights.b += lightColor.b;
} else if (light.isPointLight) {
_pointLights.r += lightColor.r;
_pointLights.g += lightColor.g;
_pointLights.b += lightColor.b;
}
}
}
function calculateLight(lights, position, normal, color) {
for (let l = 0, ll = lights.length; l < ll; l++) {
const light = lights[l];
const lightColor = light.color;
if (light.isDirectionalLight) {
const lightPosition = _vector3.setFromMatrixPosition(light.matrixWorld).normalize();
let amount = normal.dot(lightPosition);
if (amount <= 0) continue;
amount *= light.intensity;
color.r += lightColor.r * amount;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
} else if (light.isPointLight) {
const lightPosition = _vector3.setFromMatrixPosition(light.matrixWorld);
let amount = normal.dot(_vector3.subVectors(lightPosition, position).normalize());
if (amount <= 0) continue;
amount *= light.distance == 0 ? 1 : 1 - Math.min(position.distanceTo(lightPosition) / light.distance, 1);
if (amount == 0) continue;
amount *= light.intensity;
color.r += lightColor.r * amount;
color.g += lightColor.g * amount;
color.b += lightColor.b * amount;
}
}
}
function renderSprite(v1, element, material) {
let scaleX = element.scale.x * _svgWidthHalf;
let scaleY = element.scale.y * _svgHeightHalf;
if (material.isPointsMaterial) {
scaleX *= material.size;
scaleY *= material.size;
}
const path = "M" + convert(v1.x - scaleX * .5) + "," + convert(v1.y - scaleY * .5) + "h" + convert(scaleX) + "v" + convert(scaleY) + "h" + convert(-scaleX) + "z";
let style = "";
if (material.isSpriteMaterial || material.isPointsMaterial) style = "fill:" + material.color.getStyle() + ";fill-opacity:" + material.opacity;
addPath(style, path);
}
function renderLine(v1, v2, material) {
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(v2.positionScreen.x) + "," + convert(v2.positionScreen.y);
if (material.isLineBasicMaterial) {
let style = "fill:none;stroke:" + material.color.getStyle() + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.linewidth + ";stroke-linecap:" + material.linecap;
if (material.isLineDashedMaterial) style = style + ";stroke-dasharray:" + material.dashSize + "," + material.gapSize;
addPath(style, path);
}
}
function renderFace3(v1, v2, v3, element, material) {
_this.info.render.vertices += 3;
_this.info.render.faces++;
const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(v2.positionScreen.x) + "," + convert(v2.positionScreen.y) + "L" + convert(v3.positionScreen.x) + "," + convert(v3.positionScreen.y) + "z";
let style = "";
if (material.isMeshBasicMaterial) {
_color.copy(material.color);
if (material.vertexColors) _color.multiply(element.color);
} else if (material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial) {
_diffuseColor.copy(material.color);
if (material.vertexColors) _diffuseColor.multiply(element.color);
_color.copy(_ambientLight);
_centroid.copy(v1.positionWorld).add(v2.positionWorld).add(v3.positionWorld).divideScalar(3);
calculateLight(_lights, _centroid, element.normalModel, _color);
_color.multiply(_diffuseColor).add(material.emissive);
} else if (material.isMeshNormalMaterial) {
_normal.copy(element.normalModel).applyMatrix3(_normalViewMatrix).normalize();
_color.setRGB(_normal.x, _normal.y, _normal.z).multiplyScalar(.5).addScalar(.5);
}
if (material.wireframe) style = "fill:none;stroke:" + _color.getStyle() + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.wireframeLinewidth + ";stroke-linecap:" + material.wireframeLinecap + ";stroke-linejoin:" + material.wireframeLinejoin;
else style = "fill:" + _color.getStyle() + ";fill-opacity:" + material.opacity;
addPath(style, path);
}
function expand(v1, v2, pixels) {
let x = v2.x - v1.x, y = v2.y - v1.y;
const det = x * x + y * y;
if (det === 0) return;
const idet = pixels / Math.sqrt(det);
x *= idet;
y *= idet;
v2.x += x;
v2.y += y;
v1.x -= x;
v1.y -= y;
}
function addPath(style, path) {
if (_currentStyle === style) _currentPath += path;
else {
flushPath();
_currentStyle = style;
_currentPath = path;
}
}
function flushPath() {
if (_currentPath) {
_svgNode = getPathNode(_pathCount++);
_svgNode.setAttribute("d", _currentPath);
_svgNode.setAttribute("style", _currentStyle);
_svg.appendChild(_svgNode);
}
_currentPath = "";
_currentStyle = "";
}
function getPathNode(id) {
if (_svgPathPool[id] == null) {
_svgPathPool[id] = document.createElementNS("http://www.w3.org/2000/svg", "path");
if (_quality == 0) _svgPathPool[id].setAttribute("shape-rendering", "crispEdges");
return _svgPathPool[id];
}
return _svgPathPool[id];
}
}
};
//#endregion
//#region node_modules/three-stdlib/textures/FlakesTexture.js
var FlakesTexture = class {
constructor(width = 512, height = 512) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
context.fillStyle = "rgb(127,127,255)";
context.fillRect(0, 0, width, height);
for (let i = 0; i < 4e3; i++) {
const x = Math.random() * width;
const y = Math.random() * height;
const r = Math.random() * 3 + 3;
let nx = Math.random() * 2 - 1;
let ny = Math.random() * 2 - 1;
let nz = 1.5;
const l = Math.sqrt(nx * nx + ny * ny + nz * nz);
nx /= l;
ny /= l;
nz /= l;
context.fillStyle = "rgb(" + (nx * 127 + 127) + "," + (ny * 127 + 127) + "," + nz * 255 + ")";
context.beginPath();
context.arc(x, y, r, 0, Math.PI * 2);
context.fill();
}
return canvas;
}
};
//#endregion
//#region node_modules/three-stdlib/modifiers/CurveModifier.js
var __defProp$58 = Object.defineProperty;
var __defNormalProp$58 = (obj, key, value) => key in obj ? __defProp$58(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$58 = (obj, key, value) => {
__defNormalProp$58(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var CHANNELS = 4;
var TEXTURE_WIDTH = 1024;
var TEXTURE_HEIGHT = 4;
var initSplineTexture = (numberOfCurves = 1) => {
const dataTexture = new DataTexture(new Float32Array(TEXTURE_WIDTH * TEXTURE_HEIGHT * numberOfCurves * CHANNELS), TEXTURE_WIDTH, TEXTURE_HEIGHT * numberOfCurves, RGBAFormat, FloatType);
dataTexture.wrapS = RepeatWrapping;
dataTexture.wrapT = RepeatWrapping;
dataTexture.magFilter = NearestFilter;
dataTexture.needsUpdate = true;
return dataTexture;
};
var updateSplineTexture = (texture, splineCurve, offset = 0) => {
const numberOfPoints = Math.floor(TEXTURE_WIDTH * (TEXTURE_HEIGHT / 4));
splineCurve.arcLengthDivisions = numberOfPoints / 2;
splineCurve.updateArcLengths();
const points = splineCurve.getSpacedPoints(numberOfPoints);
const frenetFrames = splineCurve.computeFrenetFrames(numberOfPoints, true);
for (let i = 0; i < numberOfPoints; i++) {
const rowOffset = Math.floor(i / TEXTURE_WIDTH);
const rowIndex = i % TEXTURE_WIDTH;
let pt = points[i];
setTextureValue(texture, rowIndex, pt.x, pt.y, pt.z, 0 + rowOffset + TEXTURE_HEIGHT * offset);
pt = frenetFrames.tangents[i];
setTextureValue(texture, rowIndex, pt.x, pt.y, pt.z, 1 + rowOffset + TEXTURE_HEIGHT * offset);
pt = frenetFrames.normals[i];
setTextureValue(texture, rowIndex, pt.x, pt.y, pt.z, 2 + rowOffset + TEXTURE_HEIGHT * offset);
pt = frenetFrames.binormals[i];
setTextureValue(texture, rowIndex, pt.x, pt.y, pt.z, 3 + rowOffset + TEXTURE_HEIGHT * offset);
}
texture.needsUpdate = true;
};
var setTextureValue = (texture, index, x, y, z, o) => {
const { data } = texture.image;
const i = CHANNELS * TEXTURE_WIDTH * o;
data[index * CHANNELS + i + 0] = x;
data[index * CHANNELS + i + 1] = y;
data[index * CHANNELS + i + 2] = z;
data[index * CHANNELS + i + 3] = 1;
};
var getUniforms = (splineTexture) => ({
spineTexture: { value: splineTexture },
pathOffset: {
type: "f",
value: 0
},
pathSegment: {
type: "f",
value: 1
},
spineOffset: {
type: "f",
value: 161
},
spineLength: {
type: "f",
value: 400
},
flow: {
type: "i",
value: 1
}
});
function modifyShader(material, uniforms, numberOfCurves = 1) {
if (material.__ok) return;
material.__ok = true;
material.onBeforeCompile = (shader) => {
if (shader.__modified) return;
shader.__modified = true;
Object.assign(shader.uniforms, uniforms);
shader.vertexShader = `
uniform sampler2D spineTexture;
uniform float pathOffset;
uniform float pathSegment;
uniform float spineOffset;
uniform float spineLength;
uniform int flow;
float textureLayers = ${TEXTURE_HEIGHT * numberOfCurves}.;
float textureStacks = ${TEXTURE_HEIGHT / 4}.;
${shader.vertexShader}
`.replace("#include ", "").replace("#include ", "").replace("#include ", "").replace(/void\s*main\s*\(\)\s*\{/, `
void main() {
#include
vec4 worldPos = modelMatrix * vec4(position, 1.);
bool bend = flow > 0;
float xWeight = bend ? 0. : 1.;
#ifdef USE_INSTANCING
float pathOffsetFromInstanceMatrix = instanceMatrix[3][2];
float spineLengthFromInstanceMatrix = instanceMatrix[3][0];
float spinePortion = bend ? (worldPos.x + spineOffset) / spineLengthFromInstanceMatrix : 0.;
float mt = (spinePortion * pathSegment + pathOffset + pathOffsetFromInstanceMatrix)*textureStacks;
#else
float spinePortion = bend ? (worldPos.x + spineOffset) / spineLength : 0.;
float mt = (spinePortion * pathSegment + pathOffset)*textureStacks;
#endif
mt = mod(mt, textureStacks);
float rowOffset = floor(mt);
#ifdef USE_INSTANCING
rowOffset += instanceMatrix[3][1] * ${TEXTURE_HEIGHT}.;
#endif
vec3 spinePos = texture2D(spineTexture, vec2(mt, (0. + rowOffset + 0.5) / textureLayers)).xyz;
vec3 a = texture2D(spineTexture, vec2(mt, (1. + rowOffset + 0.5) / textureLayers)).xyz;
vec3 b = texture2D(spineTexture, vec2(mt, (2. + rowOffset + 0.5) / textureLayers)).xyz;
vec3 c = texture2D(spineTexture, vec2(mt, (3. + rowOffset + 0.5) / textureLayers)).xyz;
mat3 basis = mat3(a, b, c);
vec3 transformed = basis
* vec3(worldPos.x * xWeight, worldPos.y * 1., worldPos.z * 1.)
+ spinePos;
vec3 transformedNormal = normalMatrix * (basis * objectNormal);
`).replace("#include ", `vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );
gl_Position = projectionMatrix * mvPosition;`);
};
}
var Flow = class {
/**
* @param {Mesh} mesh The mesh to clone and modify to bend around the curve
* @param {number} numberOfCurves The amount of space that should preallocated for additional curves
*/
constructor(mesh, numberOfCurves = 1) {
__publicField$58(this, "curveArray");
__publicField$58(this, "curveLengthArray");
__publicField$58(this, "object3D");
__publicField$58(this, "splineTexure");
__publicField$58(this, "uniforms");
const obj3D = mesh.clone();
const splineTexure = initSplineTexture(numberOfCurves);
const uniforms = getUniforms(splineTexure);
obj3D.traverse((child) => {
if (child instanceof Mesh || child instanceof InstancedMesh) {
child.material = child.material.clone();
modifyShader(child.material, uniforms, numberOfCurves);
}
});
this.curveArray = new Array(numberOfCurves);
this.curveLengthArray = new Array(numberOfCurves);
this.object3D = obj3D;
this.splineTexure = splineTexure;
this.uniforms = uniforms;
}
updateCurve(index, curve) {
if (index >= this.curveArray.length) throw Error("Index out of range for Flow");
const curveLength = curve.getLength();
this.uniforms.spineLength.value = curveLength;
this.curveLengthArray[index] = curveLength;
this.curveArray[index] = curve;
updateSplineTexture(this.splineTexure, curve, index);
}
moveAlongCurve(amount) {
this.uniforms.pathOffset.value += amount;
}
};
var matrix$1 = /* @__PURE__ */ new Matrix4();
var InstancedFlow = class extends Flow {
/**
*
* @param {number} count The number of instanced elements
* @param {number} curveCount The number of curves to preallocate for
* @param {Geometry} geometry The geometry to use for the instanced mesh
* @param {Material} material The material to use for the instanced mesh
*/
constructor(count, curveCount, geometry, material) {
const mesh = new InstancedMesh(geometry, material, count);
mesh.instanceMatrix.setUsage(DynamicDrawUsage);
mesh.frustumCulled = false;
super(mesh, curveCount);
__publicField$58(this, "offsets");
__publicField$58(this, "whichCurve");
this.offsets = new Array(count).fill(0);
this.whichCurve = new Array(count).fill(0);
}
/**
* The extra information about which curve and curve position is stored in the translation components of the matrix for the instanced objects
* This writes that information to the matrix and marks it as needing update.
*
* @param {number} index of the instanced element to update
*/
writeChanges(index) {
matrix$1.makeTranslation(this.curveLengthArray[this.whichCurve[index]], this.whichCurve[index], this.offsets[index]);
this.object3D.setMatrixAt(index, matrix$1);
this.object3D.instanceMatrix.needsUpdate = true;
}
/**
* Move an individual element along the curve by a specific amount
*
* @param {number} index Which element to update
* @param {number} offset Move by how much
*/
moveIndividualAlongCurve(index, offset) {
this.offsets[index] += offset;
this.writeChanges(index);
}
/**
* Select which curve to use for an element
*
* @param {number} index the index of the instanced element to update
* @param {number} curveNo the index of the curve it should use
*/
setCurve(index, curveNo) {
if (isNaN(curveNo)) throw Error("curve index being set is Not a Number (NaN)");
this.whichCurve[index] = curveNo;
this.writeChanges(index);
}
};
//#endregion
//#region node_modules/three-stdlib/types/helpers.js
var getWithKey = (obj, key) => obj[key];
//#endregion
//#region node_modules/three-stdlib/utils/BufferGeometryUtils.js
var BufferGeometryUtils_exports = /* @__PURE__ */ __exportAll({
computeMorphedAttributes: () => computeMorphedAttributes,
estimateBytesUsed: () => estimateBytesUsed,
interleaveAttributes: () => interleaveAttributes,
mergeBufferAttributes: () => mergeBufferAttributes,
mergeBufferGeometries: () => mergeBufferGeometries,
mergeVertices: () => mergeVertices,
toCreasedNormals: () => toCreasedNormals,
toTrianglesDrawMode: () => toTrianglesDrawMode
});
var mergeBufferGeometries = (geometries, useGroups) => {
const isIndexed = geometries[0].index !== null;
const attributesUsed = new Set(Object.keys(geometries[0].attributes));
const morphAttributesUsed = new Set(Object.keys(geometries[0].morphAttributes));
const attributes = {};
const morphAttributes = {};
const morphTargetsRelative = geometries[0].morphTargetsRelative;
const mergedGeometry = new BufferGeometry();
let offset = 0;
geometries.forEach((geom, i) => {
let attributesCount = 0;
if (isIndexed !== (geom.index !== null)) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
return null;
}
for (let name in geom.attributes) {
if (!attributesUsed.has(name)) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". All geometries must have compatible attributes; make sure \"" + name + "\" attribute exists among all geometries, or in none of them.");
return null;
}
if (attributes[name] === void 0) attributes[name] = [];
attributes[name].push(geom.attributes[name]);
attributesCount++;
}
if (attributesCount !== attributesUsed.size) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". Make sure all geometries have the same number of attributes.");
return null;
}
if (morphTargetsRelative !== geom.morphTargetsRelative) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". .morphTargetsRelative must be consistent throughout all geometries.");
return null;
}
for (let name in geom.morphAttributes) {
if (!morphAttributesUsed.has(name)) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". .morphAttributes must be consistent throughout all geometries.");
return null;
}
if (morphAttributes[name] === void 0) morphAttributes[name] = [];
morphAttributes[name].push(geom.morphAttributes[name]);
}
mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || [];
mergedGeometry.userData.mergedUserData.push(geom.userData);
if (useGroups) {
let count;
if (geom.index) count = geom.index.count;
else if (geom.attributes.position !== void 0) count = geom.attributes.position.count;
else {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index " + i + ". The geometry must have either an index or a position attribute");
return null;
}
mergedGeometry.addGroup(offset, count, i);
offset += count;
}
});
if (isIndexed) {
let indexOffset = 0;
const mergedIndex = [];
geometries.forEach((geom) => {
const index = geom.index;
for (let j = 0; j < index.count; ++j) mergedIndex.push(index.getX(j) + indexOffset);
indexOffset += geom.attributes.position.count;
});
mergedGeometry.setIndex(mergedIndex);
}
for (let name in attributes) {
const mergedAttribute = mergeBufferAttributes(attributes[name]);
if (!mergedAttribute) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the " + name + " attribute.");
return null;
}
mergedGeometry.setAttribute(name, mergedAttribute);
}
for (let name in morphAttributes) {
const numMorphTargets = morphAttributes[name][0].length;
if (numMorphTargets === 0) break;
mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {};
mergedGeometry.morphAttributes[name] = [];
for (let i = 0; i < numMorphTargets; ++i) {
const morphAttributesToMerge = [];
for (let j = 0; j < morphAttributes[name].length; ++j) morphAttributesToMerge.push(morphAttributes[name][j][i]);
const mergedMorphAttribute = mergeBufferAttributes(morphAttributesToMerge);
if (!mergedMorphAttribute) {
console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the " + name + " morphAttribute.");
return null;
}
mergedGeometry.morphAttributes[name].push(mergedMorphAttribute);
}
}
return mergedGeometry;
};
var mergeBufferAttributes = (attributes) => {
let TypedArray = void 0;
let itemSize = void 0;
let normalized = void 0;
let arrayLength = 0;
attributes.forEach((attr) => {
if (TypedArray === void 0) TypedArray = attr.array.constructor;
if (TypedArray !== attr.array.constructor) {
console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.");
return null;
}
if (itemSize === void 0) itemSize = attr.itemSize;
if (itemSize !== attr.itemSize) {
console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.");
return null;
}
if (normalized === void 0) normalized = attr.normalized;
if (normalized !== attr.normalized) {
console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.");
return null;
}
arrayLength += attr.array.length;
});
if (TypedArray && itemSize) {
const array = new TypedArray(arrayLength);
let offset = 0;
attributes.forEach((attr) => {
array.set(attr.array, offset);
offset += attr.array.length;
});
return new BufferAttribute(array, itemSize, normalized);
}
};
var interleaveAttributes = (attributes) => {
let TypedArray = void 0;
let arrayLength = 0;
let stride = 0;
for (let i = 0, l = attributes.length; i < l; ++i) {
const attribute = attributes[i];
if (TypedArray === void 0) TypedArray = attribute.array.constructor;
if (TypedArray !== attribute.array.constructor) {
console.error("AttributeBuffers of different types cannot be interleaved");
return null;
}
arrayLength += attribute.array.length;
stride += attribute.itemSize;
}
const interleavedBuffer = new InterleavedBuffer(new TypedArray(arrayLength), stride);
let offset = 0;
const res = [];
const getters = [
"getX",
"getY",
"getZ",
"getW"
];
const setters = [
"setX",
"setY",
"setZ",
"setW"
];
for (let j = 0, l = attributes.length; j < l; j++) {
const attribute = attributes[j];
const itemSize = attribute.itemSize;
const count = attribute.count;
const iba = new InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
res.push(iba);
offset += itemSize;
for (let c = 0; c < count; c++) for (let k = 0; k < itemSize; k++) {
const set = getWithKey(iba, setters[k]);
const get = getWithKey(attribute, getters[k]);
set(c, get(c));
}
}
return res;
};
function estimateBytesUsed(geometry) {
let mem = 0;
for (let name in geometry.attributes) {
const attr = geometry.getAttribute(name);
mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT;
}
const indices = geometry.getIndex();
mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;
return mem;
}
function mergeVertices(geometry, tolerance = 1e-4) {
tolerance = Math.max(tolerance, Number.EPSILON);
const hashToIndex = {};
const indices = geometry.getIndex();
const positions = geometry.getAttribute("position");
const vertexCount = indices ? indices.count : positions.count;
let nextIndex = 0;
const attributeNames = Object.keys(geometry.attributes);
const attrArrays = {};
const morphAttrsArrays = {};
const newIndices = [];
const getters = [
"getX",
"getY",
"getZ",
"getW"
];
for (let i = 0, l = attributeNames.length; i < l; i++) {
const name = attributeNames[i];
attrArrays[name] = [];
const morphAttr = geometry.morphAttributes[name];
if (morphAttr) morphAttrsArrays[name] = new Array(morphAttr.length).fill(0).map(() => []);
}
const decimalShift = Math.log10(1 / tolerance);
const shiftMultiplier = Math.pow(10, decimalShift);
for (let i = 0; i < vertexCount; i++) {
const index = indices ? indices.getX(i) : i;
let hash = "";
for (let j = 0, l = attributeNames.length; j < l; j++) {
const name = attributeNames[j];
const attribute = geometry.getAttribute(name);
const itemSize = attribute.itemSize;
for (let k = 0; k < itemSize; k++) hash += `${~~(attribute[getters[k]](index) * shiftMultiplier)},`;
}
if (hash in hashToIndex) newIndices.push(hashToIndex[hash]);
else {
for (let j = 0, l = attributeNames.length; j < l; j++) {
const name = attributeNames[j];
const attribute = geometry.getAttribute(name);
const morphAttr = geometry.morphAttributes[name];
const itemSize = attribute.itemSize;
const newarray = attrArrays[name];
const newMorphArrays = morphAttrsArrays[name];
for (let k = 0; k < itemSize; k++) {
const getterFunc = getters[k];
newarray.push(attribute[getterFunc](index));
if (morphAttr) for (let m = 0, ml = morphAttr.length; m < ml; m++) newMorphArrays[m].push(morphAttr[m][getterFunc](index));
}
}
hashToIndex[hash] = nextIndex;
newIndices.push(nextIndex);
nextIndex++;
}
}
const result = geometry.clone();
for (let i = 0, l = attributeNames.length; i < l; i++) {
const name = attributeNames[i];
const oldAttribute = geometry.getAttribute(name);
const attribute = new BufferAttribute(new oldAttribute.array.constructor(attrArrays[name]), oldAttribute.itemSize, oldAttribute.normalized);
result.setAttribute(name, attribute);
if (name in morphAttrsArrays) for (let j = 0; j < morphAttrsArrays[name].length; j++) {
const oldMorphAttribute = geometry.morphAttributes[name][j];
const morphAttribute = new BufferAttribute(new oldMorphAttribute.array.constructor(morphAttrsArrays[name][j]), oldMorphAttribute.itemSize, oldMorphAttribute.normalized);
result.morphAttributes[name][j] = morphAttribute;
}
}
result.setIndex(newIndices);
return result;
}
function toTrianglesDrawMode(geometry, drawMode) {
if (drawMode === 0) {
console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
return geometry;
}
if (drawMode === 2 || drawMode === 1) {
let index = geometry.getIndex();
if (index === null) {
const indices = [];
const position = geometry.getAttribute("position");
if (position !== void 0) {
for (let i = 0; i < position.count; i++) indices.push(i);
geometry.setIndex(indices);
index = geometry.getIndex();
} else {
console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.");
return geometry;
}
}
const numberOfTriangles = index.count - 2;
const newIndices = [];
if (index) if (drawMode === 2) for (let i = 1; i <= numberOfTriangles; i++) {
newIndices.push(index.getX(0));
newIndices.push(index.getX(i));
newIndices.push(index.getX(i + 1));
}
else for (let i = 0; i < numberOfTriangles; i++) if (i % 2 === 0) {
newIndices.push(index.getX(i));
newIndices.push(index.getX(i + 1));
newIndices.push(index.getX(i + 2));
} else {
newIndices.push(index.getX(i + 2));
newIndices.push(index.getX(i + 1));
newIndices.push(index.getX(i));
}
if (newIndices.length / 3 !== numberOfTriangles) console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
const newGeometry = geometry.clone();
newGeometry.setIndex(newIndices);
newGeometry.clearGroups();
return newGeometry;
} else {
console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", drawMode);
return geometry;
}
}
function computeMorphedAttributes(object) {
if (object.geometry.isBufferGeometry !== true) {
console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry.");
return null;
}
const _vA = new Vector3();
const _vB = new Vector3();
const _vC = new Vector3();
const _tempA = new Vector3();
const _tempB = new Vector3();
const _tempC = new Vector3();
const _morphA = new Vector3();
const _morphB = new Vector3();
const _morphC = new Vector3();
function _calculateMorphedAttributeData(object2, material2, attribute, morphAttribute, morphTargetsRelative2, a2, b2, c2, modifiedAttributeArray) {
_vA.fromBufferAttribute(attribute, a2);
_vB.fromBufferAttribute(attribute, b2);
_vC.fromBufferAttribute(attribute, c2);
const morphInfluences = object2.morphTargetInfluences;
if (material2.morphTargets && morphAttribute && morphInfluences) {
_morphA.set(0, 0, 0);
_morphB.set(0, 0, 0);
_morphC.set(0, 0, 0);
for (let i2 = 0, il2 = morphAttribute.length; i2 < il2; i2++) {
const influence = morphInfluences[i2];
const morph = morphAttribute[i2];
if (influence === 0) continue;
_tempA.fromBufferAttribute(morph, a2);
_tempB.fromBufferAttribute(morph, b2);
_tempC.fromBufferAttribute(morph, c2);
if (morphTargetsRelative2) {
_morphA.addScaledVector(_tempA, influence);
_morphB.addScaledVector(_tempB, influence);
_morphC.addScaledVector(_tempC, influence);
} else {
_morphA.addScaledVector(_tempA.sub(_vA), influence);
_morphB.addScaledVector(_tempB.sub(_vB), influence);
_morphC.addScaledVector(_tempC.sub(_vC), influence);
}
}
_vA.add(_morphA);
_vB.add(_morphB);
_vC.add(_morphC);
}
if (object2.isSkinnedMesh) {
object2.boneTransform(a2, _vA);
object2.boneTransform(b2, _vB);
object2.boneTransform(c2, _vC);
}
modifiedAttributeArray[a2 * 3 + 0] = _vA.x;
modifiedAttributeArray[a2 * 3 + 1] = _vA.y;
modifiedAttributeArray[a2 * 3 + 2] = _vA.z;
modifiedAttributeArray[b2 * 3 + 0] = _vB.x;
modifiedAttributeArray[b2 * 3 + 1] = _vB.y;
modifiedAttributeArray[b2 * 3 + 2] = _vB.z;
modifiedAttributeArray[c2 * 3 + 0] = _vC.x;
modifiedAttributeArray[c2 * 3 + 1] = _vC.y;
modifiedAttributeArray[c2 * 3 + 2] = _vC.z;
}
const geometry = object.geometry;
const material = object.material;
let a, b, c;
const index = geometry.index;
const positionAttribute = geometry.attributes.position;
const morphPosition = geometry.morphAttributes.position;
const morphTargetsRelative = geometry.morphTargetsRelative;
const normalAttribute = geometry.attributes.normal;
const morphNormal = geometry.morphAttributes.position;
const groups = geometry.groups;
const drawRange = geometry.drawRange;
let i, j, il, jl;
let group, groupMaterial;
let start, end;
const modifiedPosition = new Float32Array(positionAttribute.count * positionAttribute.itemSize);
const modifiedNormal = new Float32Array(normalAttribute.count * normalAttribute.itemSize);
if (index !== null) if (Array.isArray(material)) for (i = 0, il = groups.length; i < il; i++) {
group = groups[i];
groupMaterial = material[group.materialIndex];
start = Math.max(group.start, drawRange.start);
end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
for (j = start, jl = end; j < jl; j += 3) {
a = index.getX(j);
b = index.getX(j + 1);
c = index.getX(j + 2);
_calculateMorphedAttributeData(object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
_calculateMorphedAttributeData(object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
}
}
else {
start = Math.max(0, drawRange.start);
end = Math.min(index.count, drawRange.start + drawRange.count);
for (i = start, il = end; i < il; i += 3) {
a = index.getX(i);
b = index.getX(i + 1);
c = index.getX(i + 2);
_calculateMorphedAttributeData(object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
_calculateMorphedAttributeData(object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
}
}
else if (positionAttribute !== void 0) if (Array.isArray(material)) for (i = 0, il = groups.length; i < il; i++) {
group = groups[i];
groupMaterial = material[group.materialIndex];
start = Math.max(group.start, drawRange.start);
end = Math.min(group.start + group.count, drawRange.start + drawRange.count);
for (j = start, jl = end; j < jl; j += 3) {
a = j;
b = j + 1;
c = j + 2;
_calculateMorphedAttributeData(object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
_calculateMorphedAttributeData(object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
}
}
else {
start = Math.max(0, drawRange.start);
end = Math.min(positionAttribute.count, drawRange.start + drawRange.count);
for (i = start, il = end; i < il; i += 3) {
a = i;
b = i + 1;
c = i + 2;
_calculateMorphedAttributeData(object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition);
_calculateMorphedAttributeData(object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal);
}
}
return {
positionAttribute,
normalAttribute,
morphedPositionAttribute: new Float32BufferAttribute(modifiedPosition, 3),
morphedNormalAttribute: new Float32BufferAttribute(modifiedNormal, 3)
};
}
function toCreasedNormals(geometry, creaseAngle = Math.PI / 3) {
const creaseDot = Math.cos(creaseAngle);
const hashMultiplier = 1.0000000001 * 100;
const verts = [
new Vector3(),
new Vector3(),
new Vector3()
];
const tempVec1 = new Vector3();
const tempVec2 = new Vector3();
const tempNorm = new Vector3();
const tempNorm2 = new Vector3();
function hashVertex(v) {
return `${~~(v.x * hashMultiplier)},${~~(v.y * hashMultiplier)},${~~(v.z * hashMultiplier)}`;
}
const resultGeometry = geometry.index ? geometry.toNonIndexed() : geometry;
const posAttr = resultGeometry.attributes.position;
const vertexMap = {};
for (let i = 0, l = posAttr.count / 3; i < l; i++) {
const i3 = 3 * i;
const a = verts[0].fromBufferAttribute(posAttr, i3 + 0);
const b = verts[1].fromBufferAttribute(posAttr, i3 + 1);
const c = verts[2].fromBufferAttribute(posAttr, i3 + 2);
tempVec1.subVectors(c, b);
tempVec2.subVectors(a, b);
const normal = new Vector3().crossVectors(tempVec1, tempVec2).normalize();
for (let n = 0; n < 3; n++) {
const vert = verts[n];
const hash = hashVertex(vert);
if (!(hash in vertexMap)) vertexMap[hash] = [];
vertexMap[hash].push(normal);
}
}
const normAttr = new BufferAttribute(new Float32Array(posAttr.count * 3), 3, false);
for (let i = 0, l = posAttr.count / 3; i < l; i++) {
const i3 = 3 * i;
const a = verts[0].fromBufferAttribute(posAttr, i3 + 0);
const b = verts[1].fromBufferAttribute(posAttr, i3 + 1);
const c = verts[2].fromBufferAttribute(posAttr, i3 + 2);
tempVec1.subVectors(c, b);
tempVec2.subVectors(a, b);
tempNorm.crossVectors(tempVec1, tempVec2).normalize();
for (let n = 0; n < 3; n++) {
const vert = verts[n];
const otherNormals = vertexMap[hashVertex(vert)];
tempNorm2.set(0, 0, 0);
for (let k = 0, lk = otherNormals.length; k < lk; k++) {
const otherNorm = otherNormals[k];
if (tempNorm.dot(otherNorm) > creaseDot) tempNorm2.add(otherNorm);
}
tempNorm2.normalize();
normAttr.setXYZ(i3 + n, tempNorm2.x, tempNorm2.y, tempNorm2.z);
}
}
resultGeometry.setAttribute("normal", normAttr);
return resultGeometry;
}
//#endregion
//#region node_modules/three-stdlib/modifiers/SimplifyModifier.js
var __defProp$57 = Object.defineProperty;
var __defNormalProp$57 = (obj, key, value) => key in obj ? __defProp$57(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$57 = (obj, key, value) => {
__defNormalProp$57(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var cb = /* @__PURE__ */ new Vector3();
var ab = /* @__PURE__ */ new Vector3();
function pushIfUnique(array, object) {
if (array.indexOf(object) === -1) array.push(object);
}
function removeFromArray(array, object) {
const k = array.indexOf(object);
if (k > -1) array.splice(k, 1);
}
var Vertex = class {
constructor(v, id) {
__publicField$57(this, "position");
__publicField$57(this, "id");
__publicField$57(this, "faces");
__publicField$57(this, "neighbors");
__publicField$57(this, "collapseCost");
__publicField$57(this, "collapseNeighbor");
__publicField$57(this, "minCost", 0);
__publicField$57(this, "totalCost", 0);
__publicField$57(this, "costCount", 0);
this.position = v;
this.id = id;
this.faces = [];
this.neighbors = [];
this.collapseCost = 0;
this.collapseNeighbor = null;
}
addUniqueNeighbor(vertex) {
pushIfUnique(this.neighbors, vertex);
}
removeIfNonNeighbor(n) {
const neighbors = this.neighbors;
const faces = this.faces;
const offset = neighbors.indexOf(n);
if (offset === -1) return;
for (let i = 0; i < faces.length; i++) if (faces[i].hasVertex(n)) return;
neighbors.splice(offset, 1);
}
};
var Triangle = class {
constructor(v1, v2, v3, a, b, c) {
__publicField$57(this, "a");
__publicField$57(this, "b");
__publicField$57(this, "c");
__publicField$57(this, "v1");
__publicField$57(this, "v2");
__publicField$57(this, "v3");
__publicField$57(this, "normal", new Vector3());
this.a = a;
this.b = b;
this.c = c;
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
this.computeNormal();
v1.faces.push(this);
v1.addUniqueNeighbor(v2);
v1.addUniqueNeighbor(v3);
v2.faces.push(this);
v2.addUniqueNeighbor(v1);
v2.addUniqueNeighbor(v3);
v3.faces.push(this);
v3.addUniqueNeighbor(v1);
v3.addUniqueNeighbor(v2);
}
computeNormal() {
const vA = this.v1.position;
const vB = this.v2.position;
const vC = this.v3.position;
cb.subVectors(vC, vB);
ab.subVectors(vA, vB);
cb.cross(ab).normalize();
this.normal.copy(cb);
}
hasVertex(v) {
return v === this.v1 || v === this.v2 || v === this.v3;
}
replaceVertex(oldv, newv) {
if (oldv === this.v1) this.v1 = newv;
else if (oldv === this.v2) this.v2 = newv;
else if (oldv === this.v3) this.v3 = newv;
removeFromArray(oldv.faces, this);
newv.faces.push(this);
oldv.removeIfNonNeighbor(this.v1);
this.v1.removeIfNonNeighbor(oldv);
oldv.removeIfNonNeighbor(this.v2);
this.v2.removeIfNonNeighbor(oldv);
oldv.removeIfNonNeighbor(this.v3);
this.v3.removeIfNonNeighbor(oldv);
this.v1.addUniqueNeighbor(this.v2);
this.v1.addUniqueNeighbor(this.v3);
this.v2.addUniqueNeighbor(this.v1);
this.v2.addUniqueNeighbor(this.v3);
this.v3.addUniqueNeighbor(this.v1);
this.v3.addUniqueNeighbor(this.v2);
this.computeNormal();
}
};
var SimplifyModifier = class {
constructor() {
__publicField$57(this, "computeEdgeCollapseCost", (u, v) => {
const edgelength = v.position.distanceTo(u.position);
let curvature = 0;
const sideFaces = [];
let i, il = u.faces.length, face, sideFace;
for (i = 0; i < il; i++) {
face = u.faces[i];
if (face.hasVertex(v)) sideFaces.push(face);
}
for (i = 0; i < il; i++) {
let minCurvature = 1;
face = u.faces[i];
for (let j = 0; j < sideFaces.length; j++) {
sideFace = sideFaces[j];
const dotProd = face.normal.dot(sideFace.normal);
minCurvature = Math.min(minCurvature, (1.001 - dotProd) / 2);
}
curvature = Math.max(curvature, minCurvature);
}
const borders = 0;
if (sideFaces.length < 2) curvature = 1;
return edgelength * curvature + borders;
});
__publicField$57(this, "computeEdgeCostAtVertex", (v) => {
if (v.neighbors.length === 0) {
v.collapseNeighbor = null;
v.collapseCost = -.01;
return;
}
v.collapseCost = 1e5;
v.collapseNeighbor = null;
for (let i = 0; i < v.neighbors.length; i++) {
const collapseCost = this.computeEdgeCollapseCost(v, v.neighbors[i]);
if (!v.collapseNeighbor) {
v.collapseNeighbor = v.neighbors[i];
v.collapseCost = collapseCost;
v.minCost = collapseCost;
v.totalCost = 0;
v.costCount = 0;
}
v.costCount++;
v.totalCost += collapseCost;
if (collapseCost < v.minCost) {
v.collapseNeighbor = v.neighbors[i];
v.minCost = collapseCost;
}
}
v.collapseCost = v.totalCost / v.costCount;
});
__publicField$57(this, "removeFace", (f, faces) => {
removeFromArray(faces, f);
if (f.v1) removeFromArray(f.v1.faces, f);
if (f.v2) removeFromArray(f.v2.faces, f);
if (f.v3) removeFromArray(f.v3.faces, f);
const vs = [
f.v1,
f.v2,
f.v3
];
let v1, v2;
for (let i = 0; i < 3; i++) {
v1 = vs[i];
v2 = vs[(i + 1) % 3];
if (!v1 || !v2) continue;
v1.removeIfNonNeighbor(v2);
v2.removeIfNonNeighbor(v1);
}
});
__publicField$57(this, "collapse", (vertices, faces, u, v) => {
if (!v) {
this.removeVertex(u, vertices);
return;
}
let i;
const tmpVertices = [];
for (i = 0; i < u.neighbors.length; i++) tmpVertices.push(u.neighbors[i]);
for (i = u.faces.length - 1; i >= 0; i--) if (u.faces[i].hasVertex(v)) this.removeFace(u.faces[i], faces);
for (i = u.faces.length - 1; i >= 0; i--) u.faces[i].replaceVertex(u, v);
this.removeVertex(u, vertices);
for (i = 0; i < tmpVertices.length; i++) this.computeEdgeCostAtVertex(tmpVertices[i]);
});
__publicField$57(this, "minimumCostEdge", (vertices) => {
let least = vertices[0];
for (let i = 0; i < vertices.length; i++) if (vertices[i].collapseCost < least.collapseCost) least = vertices[i];
return least;
});
__publicField$57(this, "modify", (geometry, count) => {
geometry = geometry.clone();
const attributes = geometry.attributes;
for (let name in attributes) if (name !== "position") geometry.deleteAttribute(name);
geometry = mergeVertices(geometry);
const vertices = [];
const faces = [];
const positionAttribute = geometry.getAttribute("position");
for (let i = 0; i < positionAttribute.count; i++) {
const vertex = new Vertex(new Vector3().fromBufferAttribute(positionAttribute, i), i);
vertices.push(vertex);
}
const geomIndex = geometry.getIndex();
if (geomIndex !== null) for (let i = 0; i < geomIndex.count; i += 3) {
const a = geomIndex.getX(i);
const b = geomIndex.getX(i + 1);
const c = geomIndex.getX(i + 2);
const triangle = new Triangle(vertices[a], vertices[b], vertices[c], a, b, c);
faces.push(triangle);
}
else for (let i = 0; i < positionAttribute.count; i += 3) {
const a = i;
const b = i + 1;
const c = i + 2;
const triangle = new Triangle(vertices[a], vertices[b], vertices[c], a, b, c);
faces.push(triangle);
}
for (let i = 0, il = vertices.length; i < il; i++) this.computeEdgeCostAtVertex(vertices[i]);
let nextVertex;
let z = count;
while (z--) {
nextVertex = this.minimumCostEdge(vertices);
if (!nextVertex) {
console.log("THREE.SimplifyModifier: No next vertex");
break;
} else this.collapse(vertices, faces, nextVertex, nextVertex.collapseNeighbor);
}
const simplifiedGeometry = new BufferGeometry();
const position = [];
let index = [];
for (let i = 0; i < vertices.length; i++) {
const vertex = vertices[i].position;
position.push(vertex.x, vertex.y, vertex.z);
}
for (let i = 0; i < faces.length; i++) {
const face = faces[i];
const a = vertices.indexOf(face.v1);
const b = vertices.indexOf(face.v2);
const c = vertices.indexOf(face.v3);
index.push(a, b, c);
}
simplifiedGeometry.setAttribute("position", new Float32BufferAttribute(position, 3));
simplifiedGeometry.setIndex(index);
return simplifiedGeometry;
});
}
removeVertex(v, vertices) {
console.assert(v.faces.length === 0);
while (v.neighbors.length) removeFromArray(v.neighbors.pop().neighbors, v);
removeFromArray(vertices, v);
}
};
//#endregion
//#region node_modules/three-stdlib/modifiers/EdgeSplitModifier.js
var __defProp$56 = Object.defineProperty;
var __defNormalProp$56 = (obj, key, value) => key in obj ? __defProp$56(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$56 = (obj, key, value) => {
__defNormalProp$56(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var EdgeSplitModifier = class {
constructor() {
__publicField$56(this, "A", new Vector3());
__publicField$56(this, "B", new Vector3());
__publicField$56(this, "C", new Vector3());
__publicField$56(this, "positions", []);
__publicField$56(this, "normals", new Float32Array());
__publicField$56(this, "indexes", []);
__publicField$56(this, "pointToIndexMap", []);
__publicField$56(this, "splitIndexes", []);
__publicField$56(this, "oldNormals", []);
__publicField$56(this, "computeNormals", () => {
this.normals = new Float32Array(this.indexes.length * 3);
for (let i = 0; i < this.indexes.length; i += 3) {
let index = this.indexes[i];
this.A.set(this.positions[3 * index], this.positions[3 * index + 1], this.positions[3 * index + 2]);
index = this.indexes[i + 1];
this.B.set(this.positions[3 * index], this.positions[3 * index + 1], this.positions[3 * index + 2]);
index = this.indexes[i + 2];
this.C.set(this.positions[3 * index], this.positions[3 * index + 1], this.positions[3 * index + 2]);
this.C.sub(this.B);
this.A.sub(this.B);
const normal = this.C.cross(this.A).normalize();
for (let j = 0; j < 3; j++) {
this.normals[3 * (i + j)] = normal.x;
this.normals[3 * (i + j) + 1] = normal.y;
this.normals[3 * (i + j) + 2] = normal.z;
}
}
});
__publicField$56(this, "mapPositionsToIndexes", () => {
this.pointToIndexMap = Array(this.positions.length / 3);
for (let i = 0; i < this.indexes.length; i++) {
const index = this.indexes[i];
if (this.pointToIndexMap[index] == null) this.pointToIndexMap[index] = [];
this.pointToIndexMap[index].push(i);
}
});
__publicField$56(this, "edgeSplitToGroups", (indexes, cutOff, firstIndex) => {
this.A.set(this.normals[3 * firstIndex], this.normals[3 * firstIndex + 1], this.normals[3 * firstIndex + 2]).normalize();
const result = {
splitGroup: [],
currentGroup: [firstIndex]
};
for (let j of indexes) if (j !== firstIndex) {
this.B.set(this.normals[3 * j], this.normals[3 * j + 1], this.normals[3 * j + 2]).normalize();
if (this.B.dot(this.A) < cutOff) result.splitGroup.push(j);
else result.currentGroup.push(j);
}
return result;
});
__publicField$56(this, "edgeSplit", (indexes, cutOff, original = null) => {
if (indexes.length === 0) return;
const groupResults = [];
for (let index of indexes) groupResults.push(this.edgeSplitToGroups(indexes, cutOff, index));
let result = groupResults[0];
for (let groupResult of groupResults) if (groupResult.currentGroup.length > result.currentGroup.length) result = groupResult;
if (original != null) this.splitIndexes.push({
original,
indexes: result.currentGroup
});
if (result.splitGroup.length) this.edgeSplit(result.splitGroup, cutOff, original || result.currentGroup[0]);
});
__publicField$56(this, "modify", (geometry, cutOffAngle, tryKeepNormals = true) => {
let hadNormals = false;
if (geometry.attributes.normal) {
hadNormals = true;
geometry = geometry.clone();
if (tryKeepNormals === true && geometry.index !== null) this.oldNormals = geometry.attributes.normal.array;
geometry.deleteAttribute("normal");
}
if (geometry.index == null) {
if (BufferGeometryUtils_exports === void 0) throw "THREE.EdgeSplitModifier relies on BufferGeometryUtils";
geometry = mergeVertices(geometry);
}
this.indexes = geometry.index.array;
this.positions = geometry.getAttribute("position").array;
this.computeNormals();
this.mapPositionsToIndexes();
this.splitIndexes = [];
for (let vertexIndexes of this.pointToIndexMap) this.edgeSplit(vertexIndexes, Math.cos(cutOffAngle) - .001);
const newAttributes = {};
for (let name of Object.keys(geometry.attributes)) {
const oldAttribute = geometry.attributes[name];
const newArray = new oldAttribute.array.constructor((this.indexes.length + this.splitIndexes.length) * oldAttribute.itemSize);
newArray.set(oldAttribute.array);
newAttributes[name] = new BufferAttribute(newArray, oldAttribute.itemSize, oldAttribute.normalized);
}
const newIndexes = new Uint32Array(this.indexes.length);
newIndexes.set(this.indexes);
for (let i = 0; i < this.splitIndexes.length; i++) {
const split = this.splitIndexes[i];
const index = this.indexes[split.original];
for (let attribute of Object.values(newAttributes)) for (let j = 0; j < attribute.itemSize; j++) attribute.array[(this.indexes.length + i) * attribute.itemSize + j] = attribute.array[index * attribute.itemSize + j];
for (let j of split.indexes) newIndexes[j] = this.indexes.length + i;
}
geometry = new BufferGeometry();
geometry.setIndex(new BufferAttribute(newIndexes, 1));
for (let name of Object.keys(newAttributes)) geometry.setAttribute(name, newAttributes[name]);
if (hadNormals) {
geometry.computeVertexNormals();
if (this.oldNormals !== null) {
const changedNormals = new Array(this.oldNormals.length / 3).fill(false);
for (let splitData of this.splitIndexes) changedNormals[splitData.original] = true;
for (let i = 0; i < changedNormals.length; i++) if (changedNormals[i] === false) for (let j = 0; j < 3; j++) geometry.attributes.normal.array[3 * i + j] = this.oldNormals[3 * i + j];
}
}
return geometry;
});
}
};
//#endregion
//#region node_modules/three-stdlib/modifiers/TessellateModifier.js
var __defProp$55 = Object.defineProperty;
var __defNormalProp$55 = (obj, key, value) => key in obj ? __defProp$55(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$55 = (obj, key, value) => {
__defNormalProp$55(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var TessellateModifier = class {
constructor(maxEdgeLength = .1, maxIterations = 6) {
__publicField$55(this, "maxEdgeLength");
__publicField$55(this, "maxIterations");
__publicField$55(this, "modify", (geometry) => {
if (geometry.index !== null) geometry = geometry.toNonIndexed();
const maxIterations = this.maxIterations;
const maxEdgeLengthSquared = this.maxEdgeLength * this.maxEdgeLength;
const va = new Vector3();
const vb = new Vector3();
const vc = new Vector3();
const vm = new Vector3();
const vs = [
va,
vb,
vc,
vm
];
const na = new Vector3();
const nb = new Vector3();
const nc = new Vector3();
const nm = new Vector3();
const ns = [
na,
nb,
nc,
nm
];
const ca = new Color();
const cb = new Color();
const cc = new Color();
const cm = new Color();
const cs = [
ca,
cb,
cc,
cm
];
const ua = new Vector2();
const ub = new Vector2();
const uc = new Vector2();
const um = new Vector2();
const us = [
ua,
ub,
uc,
um
];
const u2a = new Vector2();
const u2b = new Vector2();
const u2c = new Vector2();
const u2m = new Vector2();
const u2s = [
u2a,
u2b,
u2c,
u2m
];
const attributes = geometry.attributes;
const hasNormals = attributes.normal !== void 0;
const hasColors = attributes.color !== void 0;
const hasUVs = attributes.uv !== void 0;
const hasUV1s = attributes[UV1] !== void 0;
let positions = attributes.position.array;
let normals = hasNormals ? attributes.normal.array : null;
let colors = hasColors ? attributes.color.array : null;
let uvs = hasUVs ? attributes.uv.array : null;
let uv1s = hasUV1s ? attributes.uv1.array : null;
let positions2 = positions;
let normals2 = normals;
let colors2 = colors;
let uvs2 = uvs;
let uv1s2 = uv1s;
let iteration = 0;
let tessellating = true;
function addTriangle(a, b, c) {
const v1 = vs[a];
const v2 = vs[b];
const v3 = vs[c];
positions2.push(v1.x, v1.y, v1.z);
positions2.push(v2.x, v2.y, v2.z);
positions2.push(v3.x, v3.y, v3.z);
if (hasNormals) {
const n1 = ns[a];
const n2 = ns[b];
const n3 = ns[c];
normals2.push(n1.x, n1.y, n1.z);
normals2.push(n2.x, n2.y, n2.z);
normals2.push(n3.x, n3.y, n3.z);
}
if (hasColors) {
const c1 = cs[a];
const c2 = cs[b];
const c3 = cs[c];
colors2.push(c1.r, c1.g, c1.b);
colors2.push(c2.r, c2.g, c2.b);
colors2.push(c3.r, c3.g, c3.b);
}
if (hasUVs) {
const u1 = us[a];
const u2 = us[b];
const u3 = us[c];
uvs2.push(u1.x, u1.y);
uvs2.push(u2.x, u2.y);
uvs2.push(u3.x, u3.y);
}
if (hasUV1s) {
const u21 = u2s[a];
const u22 = u2s[b];
const u23 = u2s[c];
uv1s2.push(u21.x, u21.y);
uv1s2.push(u22.x, u22.y);
uv1s2.push(u23.x, u23.y);
}
}
while (tessellating && iteration < maxIterations) {
iteration++;
tessellating = false;
positions = positions2;
positions2 = [];
if (hasNormals) {
normals = normals2;
normals2 = [];
}
if (hasColors) {
colors = colors2;
colors2 = [];
}
if (hasUVs) {
uvs = uvs2;
uvs2 = [];
}
if (hasUV1s) {
uv1s = uv1s2;
uv1s2 = [];
}
for (let i = 0, i2 = 0, il = positions.length; i < il; i += 9, i2 += 6) {
va.fromArray(positions, i + 0);
vb.fromArray(positions, i + 3);
vc.fromArray(positions, i + 6);
if (hasNormals && normals) {
na.fromArray(normals, i + 0);
nb.fromArray(normals, i + 3);
nc.fromArray(normals, i + 6);
}
if (hasColors && colors) {
ca.fromArray(colors, i + 0);
cb.fromArray(colors, i + 3);
cc.fromArray(colors, i + 6);
}
if (hasUVs && uvs) {
ua.fromArray(uvs, i2 + 0);
ub.fromArray(uvs, i2 + 2);
uc.fromArray(uvs, i2 + 4);
}
if (hasUV1s && uv1s) {
u2a.fromArray(uv1s, i2 + 0);
u2b.fromArray(uv1s, i2 + 2);
u2c.fromArray(uv1s, i2 + 4);
}
const dab = va.distanceToSquared(vb);
const dbc = vb.distanceToSquared(vc);
const dac = va.distanceToSquared(vc);
if (dab > maxEdgeLengthSquared || dbc > maxEdgeLengthSquared || dac > maxEdgeLengthSquared) {
tessellating = true;
if (dab >= dbc && dab >= dac) {
vm.lerpVectors(va, vb, .5);
if (hasNormals) nm.lerpVectors(na, nb, .5);
if (hasColors) cm.lerpColors(ca, cb, .5);
if (hasUVs) um.lerpVectors(ua, ub, .5);
if (hasUV1s) u2m.lerpVectors(u2a, u2b, .5);
addTriangle(0, 3, 2);
addTriangle(3, 1, 2);
} else if (dbc >= dab && dbc >= dac) {
vm.lerpVectors(vb, vc, .5);
if (hasNormals) nm.lerpVectors(nb, nc, .5);
if (hasColors) cm.lerpColors(cb, cc, .5);
if (hasUVs) um.lerpVectors(ub, uc, .5);
if (hasUV1s) u2m.lerpVectors(u2b, u2c, .5);
addTriangle(0, 1, 3);
addTriangle(3, 2, 0);
} else {
vm.lerpVectors(va, vc, .5);
if (hasNormals) nm.lerpVectors(na, nc, .5);
if (hasColors) cm.lerpColors(ca, cc, .5);
if (hasUVs) um.lerpVectors(ua, uc, .5);
if (hasUV1s) u2m.lerpVectors(u2a, u2c, .5);
addTriangle(0, 1, 3);
addTriangle(3, 1, 2);
}
} else addTriangle(0, 1, 2);
}
}
const geometry2 = new BufferGeometry();
geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
if (hasNormals) geometry2.setAttribute("normal", new Float32BufferAttribute(normals2, 3));
if (hasColors) geometry2.setAttribute("color", new Float32BufferAttribute(colors2, 3));
if (hasUVs) geometry2.setAttribute("uv", new Float32BufferAttribute(uvs2, 2));
if (hasUV1s) geometry2.setAttribute(UV1, new Float32BufferAttribute(uv1s2, 2));
return geometry2;
});
this.maxEdgeLength = maxEdgeLength;
this.maxIterations = maxIterations;
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/GLTFExporter.js
var __defProp$54 = Object.defineProperty;
var __defNormalProp$54 = (obj, key, value) => key in obj ? __defProp$54(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$54 = (obj, key, value) => {
__defNormalProp$54(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
async function readAsDataURL(blob) {
const buffer = await blob.arrayBuffer();
const data = btoa(String.fromCharCode(...new Uint8Array(buffer)));
return `data:${blob.type || ""};base64,${data}`;
}
var _renderer;
var fullscreenQuadGeometry;
var fullscreenQuadMaterial;
var fullscreenQuad;
function decompress(texture, maxTextureSize = Infinity, renderer = null) {
if (!fullscreenQuadGeometry) fullscreenQuadGeometry = new PlaneGeometry(2, 2, 1, 1);
if (!fullscreenQuadMaterial) fullscreenQuadMaterial = new ShaderMaterial({
uniforms: { blitTexture: new Uniform(texture) },
vertexShader: `
varying vec2 vUv;
void main(){
vUv = uv;
gl_Position = vec4(position.xy * 1.0,0.,.999999);
}
`,
fragmentShader: `
uniform sampler2D blitTexture;
varying vec2 vUv;
void main(){
gl_FragColor = vec4(vUv.xy, 0, 1);
#ifdef IS_SRGB
gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );
#else
gl_FragColor = texture2D( blitTexture, vUv);
#endif
}
`
});
fullscreenQuadMaterial.uniforms.blitTexture.value = texture;
fullscreenQuadMaterial.defines.IS_SRGB = "colorSpace" in texture ? texture.colorSpace === "srgb" : texture.encoding === 3001;
fullscreenQuadMaterial.needsUpdate = true;
if (!fullscreenQuad) {
fullscreenQuad = new Mesh(fullscreenQuadGeometry, fullscreenQuadMaterial);
fullscreenQuad.frustrumCulled = false;
}
const _camera = new PerspectiveCamera();
const _scene = new Scene();
_scene.add(fullscreenQuad);
if (!renderer) renderer = _renderer = new WebGLRenderer({ antialias: false });
renderer.setSize(Math.min(texture.image.width, maxTextureSize), Math.min(texture.image.height, maxTextureSize));
renderer.clear();
renderer.render(_scene, _camera);
const readableTexture = new Texture(renderer.domElement);
readableTexture.minFilter = texture.minFilter;
readableTexture.magFilter = texture.magFilter;
readableTexture.wrapS = texture.wrapS;
readableTexture.wrapT = texture.wrapT;
readableTexture.name = texture.name;
if (_renderer) {
_renderer.dispose();
_renderer = null;
}
return readableTexture;
}
var KHR_mesh_quantization_ExtraAttrTypes = {
POSITION: [
"byte",
"byte normalized",
"unsigned byte",
"unsigned byte normalized",
"short",
"short normalized",
"unsigned short",
"unsigned short normalized"
],
NORMAL: ["byte normalized", "short normalized"],
TANGENT: ["byte normalized", "short normalized"],
TEXCOORD: [
"byte",
"byte normalized",
"unsigned byte",
"short",
"short normalized",
"unsigned short"
]
};
var GLTFExporter = /* @__PURE__ */ (() => {
class GLTFExporter2 {
constructor() {
this.pluginCallbacks = [];
this.register(function(writer) {
return new GLTFLightExtension(writer);
});
this.register(function(writer) {
return new GLTFMaterialsUnlitExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsTransmissionExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsVolumeExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsIorExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsSpecularExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsClearcoatExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsIridescenceExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsSheenExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsAnisotropyExtension$1(writer);
});
this.register(function(writer) {
return new GLTFMaterialsEmissiveStrengthExtension$1(writer);
});
}
register(callback) {
if (this.pluginCallbacks.indexOf(callback) === -1) this.pluginCallbacks.push(callback);
return this;
}
unregister(callback) {
if (this.pluginCallbacks.indexOf(callback) !== -1) this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(callback), 1);
return this;
}
/**
* Parse scenes and generate GLTF output
* @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
* @param {Function} onDone Callback on completed
* @param {Function} onError Callback on errors
* @param {Object} options options
*/
parse(input, onDone, onError, options) {
const writer = new GLTFWriter();
const plugins = [];
for (let i = 0, il = this.pluginCallbacks.length; i < il; i++) plugins.push(this.pluginCallbacks[i](writer));
writer.setPlugins(plugins);
writer.write(input, onDone, options).catch(onError);
}
parseAsync(input, options) {
const scope = this;
return new Promise(function(resolve, reject) {
scope.parse(input, resolve, reject, options);
});
}
}
/**
* Static utility functions
*/
__publicField$54(GLTFExporter2, "Utils", {
insertKeyframe: function(track, time) {
const tolerance = .001;
const valueSize = track.getValueSize();
const times = new track.TimeBufferType(track.times.length + 1);
const values = new track.ValueBufferType(track.values.length + valueSize);
const interpolant = track.createInterpolant(new track.ValueBufferType(valueSize));
let index;
if (track.times.length === 0) {
times[0] = time;
for (let i = 0; i < valueSize; i++) values[i] = 0;
index = 0;
} else if (time < track.times[0]) {
if (Math.abs(track.times[0] - time) < tolerance) return 0;
times[0] = time;
times.set(track.times, 1);
values.set(interpolant.evaluate(time), 0);
values.set(track.values, valueSize);
index = 0;
} else if (time > track.times[track.times.length - 1]) {
if (Math.abs(track.times[track.times.length - 1] - time) < tolerance) return track.times.length - 1;
times[times.length - 1] = time;
times.set(track.times, 0);
values.set(track.values, 0);
values.set(interpolant.evaluate(time), track.values.length);
index = times.length - 1;
} else for (let i = 0; i < track.times.length; i++) {
if (Math.abs(track.times[i] - time) < tolerance) return i;
if (track.times[i] < time && track.times[i + 1] > time) {
times.set(track.times.slice(0, i + 1), 0);
times[i + 1] = time;
times.set(track.times.slice(i + 1), i + 2);
values.set(track.values.slice(0, (i + 1) * valueSize), 0);
values.set(interpolant.evaluate(time), (i + 1) * valueSize);
values.set(track.values.slice((i + 1) * valueSize), (i + 2) * valueSize);
index = i + 1;
break;
}
}
track.times = times;
track.values = values;
return index;
},
mergeMorphTargetTracks: function(clip, root) {
const tracks = [];
const mergedTracks = {};
const sourceTracks = clip.tracks;
for (let i = 0; i < sourceTracks.length; ++i) {
let sourceTrack = sourceTracks[i];
const sourceTrackBinding = PropertyBinding.parseTrackName(sourceTrack.name);
const sourceTrackNode = PropertyBinding.findNode(root, sourceTrackBinding.nodeName);
if (sourceTrackBinding.propertyName !== "morphTargetInfluences" || sourceTrackBinding.propertyIndex === void 0) {
tracks.push(sourceTrack);
continue;
}
if (sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete && sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear) {
if (sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.");
sourceTrack = sourceTrack.clone();
sourceTrack.setInterpolation(InterpolateLinear);
}
const targetCount = sourceTrackNode.morphTargetInfluences.length;
const targetIndex = sourceTrackNode.morphTargetDictionary[sourceTrackBinding.propertyIndex];
if (targetIndex === void 0) throw new Error("THREE.GLTFExporter: Morph target name not found: " + sourceTrackBinding.propertyIndex);
let mergedTrack;
if (mergedTracks[sourceTrackNode.uuid] === void 0) {
mergedTrack = sourceTrack.clone();
const values = new mergedTrack.ValueBufferType(targetCount * mergedTrack.times.length);
for (let j = 0; j < mergedTrack.times.length; j++) values[j * targetCount + targetIndex] = mergedTrack.values[j];
mergedTrack.name = (sourceTrackBinding.nodeName || "") + ".morphTargetInfluences";
mergedTrack.values = values;
mergedTracks[sourceTrackNode.uuid] = mergedTrack;
tracks.push(mergedTrack);
continue;
}
const sourceInterpolant = sourceTrack.createInterpolant(new sourceTrack.ValueBufferType(1));
mergedTrack = mergedTracks[sourceTrackNode.uuid];
for (let j = 0; j < mergedTrack.times.length; j++) mergedTrack.values[j * targetCount + targetIndex] = sourceInterpolant.evaluate(mergedTrack.times[j]);
for (let j = 0; j < sourceTrack.times.length; j++) {
const keyframeIndex = this.insertKeyframe(mergedTrack, sourceTrack.times[j]);
mergedTrack.values[keyframeIndex * targetCount + targetIndex] = sourceTrack.values[j];
}
}
clip.tracks = tracks;
return clip;
}
});
return GLTFExporter2;
})();
var WEBGL_CONSTANTS$1 = {
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6,
BYTE: 5120,
UNSIGNED_BYTE: 5121,
SHORT: 5122,
UNSIGNED_SHORT: 5123,
INT: 5124,
UNSIGNED_INT: 5125,
FLOAT: 5126,
ARRAY_BUFFER: 34962,
ELEMENT_ARRAY_BUFFER: 34963,
NEAREST: 9728,
LINEAR: 9729,
NEAREST_MIPMAP_NEAREST: 9984,
LINEAR_MIPMAP_NEAREST: 9985,
NEAREST_MIPMAP_LINEAR: 9986,
LINEAR_MIPMAP_LINEAR: 9987,
CLAMP_TO_EDGE: 33071,
MIRRORED_REPEAT: 33648,
REPEAT: 10497
};
var KHR_MESH_QUANTIZATION = "KHR_mesh_quantization";
var THREE_TO_WEBGL = {};
THREE_TO_WEBGL[NearestFilter] = WEBGL_CONSTANTS$1.NEAREST;
THREE_TO_WEBGL[NearestMipmapNearestFilter] = WEBGL_CONSTANTS$1.NEAREST_MIPMAP_NEAREST;
THREE_TO_WEBGL[NearestMipmapLinearFilter] = WEBGL_CONSTANTS$1.NEAREST_MIPMAP_LINEAR;
THREE_TO_WEBGL[LinearFilter] = WEBGL_CONSTANTS$1.LINEAR;
THREE_TO_WEBGL[LinearMipmapNearestFilter] = WEBGL_CONSTANTS$1.LINEAR_MIPMAP_NEAREST;
THREE_TO_WEBGL[LinearMipmapLinearFilter] = WEBGL_CONSTANTS$1.LINEAR_MIPMAP_LINEAR;
THREE_TO_WEBGL[ClampToEdgeWrapping] = WEBGL_CONSTANTS$1.CLAMP_TO_EDGE;
THREE_TO_WEBGL[RepeatWrapping] = WEBGL_CONSTANTS$1.REPEAT;
THREE_TO_WEBGL[MirroredRepeatWrapping] = WEBGL_CONSTANTS$1.MIRRORED_REPEAT;
var PATH_PROPERTIES$1 = {
scale: "scale",
position: "translation",
quaternion: "rotation",
morphTargetInfluences: "weights"
};
var DEFAULT_SPECULAR_COLOR = /* @__PURE__ */ new Color();
var GLB_HEADER_BYTES = 12;
var GLB_HEADER_MAGIC = 1179937895;
var GLB_VERSION = 2;
var GLB_CHUNK_PREFIX_BYTES = 8;
var GLB_CHUNK_TYPE_JSON = 1313821514;
var GLB_CHUNK_TYPE_BIN = 5130562;
function equalArray(array1, array2) {
return array1.length === array2.length && array1.every(function(element, index) {
return element === array2[index];
});
}
function stringToArrayBuffer(text) {
return new TextEncoder().encode(text).buffer;
}
function isIdentityMatrix(matrix) {
return equalArray(matrix.elements, [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
]);
}
function getMinMax(attribute, start, count) {
const output = {
min: new Array(attribute.itemSize).fill(Number.POSITIVE_INFINITY),
max: new Array(attribute.itemSize).fill(Number.NEGATIVE_INFINITY)
};
for (let i = start; i < start + count; i++) for (let a = 0; a < attribute.itemSize; a++) {
let value;
if (attribute.itemSize > 4) value = attribute.array[i * attribute.itemSize + a];
else {
if (a === 0) value = attribute.getX(i);
else if (a === 1) value = attribute.getY(i);
else if (a === 2) value = attribute.getZ(i);
else if (a === 3) value = attribute.getW(i);
if (attribute.normalized === true) value = MathUtils.normalize(value, attribute.array);
}
output.min[a] = Math.min(output.min[a], value);
output.max[a] = Math.max(output.max[a], value);
}
return output;
}
function getPaddedBufferSize(bufferSize) {
return Math.ceil(bufferSize / 4) * 4;
}
function getPaddedArrayBuffer(arrayBuffer, paddingByte = 0) {
const paddedLength = getPaddedBufferSize(arrayBuffer.byteLength);
if (paddedLength !== arrayBuffer.byteLength) {
const array = new Uint8Array(paddedLength);
array.set(new Uint8Array(arrayBuffer));
if (paddingByte !== 0) for (let i = arrayBuffer.byteLength; i < paddedLength; i++) array[i] = paddingByte;
return array.buffer;
}
return arrayBuffer;
}
function getCanvas() {
if (typeof document === "undefined" && typeof OffscreenCanvas !== "undefined") return new OffscreenCanvas(1, 1);
return document.createElement("canvas");
}
function getToBlobPromise(canvas, mimeType) {
if (canvas.toBlob !== void 0) return new Promise((resolve) => canvas.toBlob(resolve, mimeType));
let quality;
if (mimeType === "image/jpeg") quality = .92;
else if (mimeType === "image/webp") quality = .8;
return canvas.convertToBlob({
type: mimeType,
quality
});
}
var GLTFWriter = class {
constructor() {
this.plugins = [];
this.options = {};
this.pending = [];
this.buffers = [];
this.byteOffset = 0;
this.buffers = [];
this.nodeMap = /* @__PURE__ */ new Map();
this.skins = [];
this.extensionsUsed = {};
this.extensionsRequired = {};
this.uids = /* @__PURE__ */ new Map();
this.uid = 0;
this.json = { asset: {
version: "2.0",
generator: "THREE.GLTFExporter"
} };
this.cache = {
meshes: /* @__PURE__ */ new Map(),
attributes: /* @__PURE__ */ new Map(),
attributesNormalized: /* @__PURE__ */ new Map(),
materials: /* @__PURE__ */ new Map(),
textures: /* @__PURE__ */ new Map(),
images: /* @__PURE__ */ new Map()
};
}
setPlugins(plugins) {
this.plugins = plugins;
}
/**
* Parse scenes and generate GLTF output
* @param {Scene or [THREE.Scenes]} input Scene or Array of THREE.Scenes
* @param {Function} onDone Callback on completed
* @param {Object} options options
*/
async write(input, onDone, options = {}) {
this.options = Object.assign({
binary: false,
trs: false,
onlyVisible: true,
maxTextureSize: Infinity,
animations: [],
includeCustomExtensions: false
}, options);
if (this.options.animations.length > 0) this.options.trs = true;
this.processInput(input);
await Promise.all(this.pending);
const writer = this;
const buffers = writer.buffers;
const json = writer.json;
options = writer.options;
const extensionsUsed = writer.extensionsUsed;
const extensionsRequired = writer.extensionsRequired;
const blob = new Blob(buffers, { type: "application/octet-stream" });
const extensionsUsedList = Object.keys(extensionsUsed);
const extensionsRequiredList = Object.keys(extensionsRequired);
if (extensionsUsedList.length > 0) json.extensionsUsed = extensionsUsedList;
if (extensionsRequiredList.length > 0) json.extensionsRequired = extensionsRequiredList;
if (json.buffers && json.buffers.length > 0) json.buffers[0].byteLength = blob.size;
if (options.binary === true) blob.arrayBuffer().then((result) => {
const binaryChunk = getPaddedArrayBuffer(result);
const binaryChunkPrefix = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));
binaryChunkPrefix.setUint32(0, binaryChunk.byteLength, true);
binaryChunkPrefix.setUint32(4, GLB_CHUNK_TYPE_BIN, true);
const jsonChunk = getPaddedArrayBuffer(stringToArrayBuffer(JSON.stringify(json)), 32);
const jsonChunkPrefix = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(GLB_CHUNK_PREFIX_BYTES));
jsonChunkPrefix.setUint32(0, jsonChunk.byteLength, true);
jsonChunkPrefix.setUint32(4, GLB_CHUNK_TYPE_JSON, true);
const header = /* @__PURE__ */ new ArrayBuffer(GLB_HEADER_BYTES);
const headerView = new DataView(header);
headerView.setUint32(0, GLB_HEADER_MAGIC, true);
headerView.setUint32(4, GLB_VERSION, true);
const totalByteLength = GLB_HEADER_BYTES + jsonChunkPrefix.byteLength + jsonChunk.byteLength + binaryChunkPrefix.byteLength + binaryChunk.byteLength;
headerView.setUint32(8, totalByteLength, true);
new Blob([
header,
jsonChunkPrefix,
jsonChunk,
binaryChunkPrefix,
binaryChunk
], { type: "application/octet-stream" }).arrayBuffer().then(onDone);
});
else if (json.buffers && json.buffers.length > 0) readAsDataURL(blob).then((uri) => {
json.buffers[0].uri = uri;
onDone(json);
});
else onDone(json);
}
/**
* Serializes a userData.
*
* @param {THREE.Object3D|THREE.Material} object
* @param {Object} objectDef
*/
serializeUserData(object, objectDef) {
if (Object.keys(object.userData).length === 0) return;
const options = this.options;
const extensionsUsed = this.extensionsUsed;
try {
const json = JSON.parse(JSON.stringify(object.userData));
if (options.includeCustomExtensions && json.gltfExtensions) {
if (objectDef.extensions === void 0) objectDef.extensions = {};
for (const extensionName in json.gltfExtensions) {
objectDef.extensions[extensionName] = json.gltfExtensions[extensionName];
extensionsUsed[extensionName] = true;
}
delete json.gltfExtensions;
}
if (Object.keys(json).length > 0) objectDef.extras = json;
} catch (error) {
console.warn("THREE.GLTFExporter: userData of '" + object.name + "' won't be serialized because of JSON.stringify error - " + error.message);
}
}
/**
* Returns ids for buffer attributes.
* @param {Object} object
* @return {Integer}
*/
getUID(attribute, isRelativeCopy = false) {
if (this.uids.has(attribute) === false) {
const uids2 = /* @__PURE__ */ new Map();
uids2.set(true, this.uid++);
uids2.set(false, this.uid++);
this.uids.set(attribute, uids2);
}
return this.uids.get(attribute).get(isRelativeCopy);
}
/**
* Checks if normal attribute values are normalized.
*
* @param {BufferAttribute} normal
* @returns {Boolean}
*/
isNormalizedNormalAttribute(normal) {
if (this.cache.attributesNormalized.has(normal)) return false;
const v = new Vector3();
for (let i = 0, il = normal.count; i < il; i++) if (Math.abs(v.fromBufferAttribute(normal, i).length() - 1) > 5e-4) return false;
return true;
}
/**
* Creates normalized normal buffer attribute.
*
* @param {BufferAttribute} normal
* @returns {BufferAttribute}
*
*/
createNormalizedNormalAttribute(normal) {
const cache = this.cache;
if (cache.attributesNormalized.has(normal)) return cache.attributesNormalized.get(normal);
const attribute = normal.clone();
const v = new Vector3();
for (let i = 0, il = attribute.count; i < il; i++) {
v.fromBufferAttribute(attribute, i);
if (v.x === 0 && v.y === 0 && v.z === 0) v.setX(1);
else v.normalize();
attribute.setXYZ(i, v.x, v.y, v.z);
}
cache.attributesNormalized.set(normal, attribute);
return attribute;
}
/**
* Applies a texture transform, if present, to the map definition. Requires
* the KHR_texture_transform extension.
*
* @param {Object} mapDef
* @param {THREE.Texture} texture
*/
applyTextureTransform(mapDef, texture) {
let didTransform = false;
const transformDef = {};
if (texture.offset.x !== 0 || texture.offset.y !== 0) {
transformDef.offset = texture.offset.toArray();
didTransform = true;
}
if (texture.rotation !== 0) {
transformDef.rotation = texture.rotation;
didTransform = true;
}
if (texture.repeat.x !== 1 || texture.repeat.y !== 1) {
transformDef.scale = texture.repeat.toArray();
didTransform = true;
}
if (didTransform) {
mapDef.extensions = mapDef.extensions || {};
mapDef.extensions["KHR_texture_transform"] = transformDef;
this.extensionsUsed["KHR_texture_transform"] = true;
}
}
buildMetalRoughTexture(metalnessMap, roughnessMap) {
if (metalnessMap === roughnessMap) return metalnessMap;
function getEncodingConversion(map) {
if ("colorSpace" in map ? map.colorSpace === "srgb" : map.encoding === 3001) return function SRGBToLinear(c) {
return c < .04045 ? c * .0773993808 : Math.pow(c * .9478672986 + .0521327014, 2.4);
};
return function LinearToLinear(c) {
return c;
};
}
console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");
if (metalnessMap instanceof CompressedTexture) metalnessMap = decompress(metalnessMap);
if (roughnessMap instanceof CompressedTexture) roughnessMap = decompress(roughnessMap);
const metalness = metalnessMap ? metalnessMap.image : null;
const roughness = roughnessMap ? roughnessMap.image : null;
const width = Math.max(metalness ? metalness.width : 0, roughness ? roughness.width : 0);
const height = Math.max(metalness ? metalness.height : 0, roughness ? roughness.height : 0);
const canvas = getCanvas();
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
context.fillStyle = "#00ffff";
context.fillRect(0, 0, width, height);
const composite = context.getImageData(0, 0, width, height);
if (metalness) {
context.drawImage(metalness, 0, 0, width, height);
const convert = getEncodingConversion(metalnessMap);
const data = context.getImageData(0, 0, width, height).data;
for (let i = 2; i < data.length; i += 4) composite.data[i] = convert(data[i] / 256) * 256;
}
if (roughness) {
context.drawImage(roughness, 0, 0, width, height);
const convert = getEncodingConversion(roughnessMap);
const data = context.getImageData(0, 0, width, height).data;
for (let i = 1; i < data.length; i += 4) composite.data[i] = convert(data[i] / 256) * 256;
}
context.putImageData(composite, 0, 0);
const texture = (metalnessMap || roughnessMap).clone();
texture.source = new Texture(canvas).source;
if ("colorSpace" in texture) texture.colorSpace = "";
else texture.encoding = 3e3;
texture.channel = (metalnessMap || roughnessMap).channel;
if (metalnessMap && roughnessMap && metalnessMap.channel !== roughnessMap.channel) console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.");
return texture;
}
/**
* Process a buffer to append to the default one.
* @param {ArrayBuffer} buffer
* @return {Integer}
*/
processBuffer(buffer) {
const json = this.json;
const buffers = this.buffers;
if (!json.buffers) json.buffers = [{ byteLength: 0 }];
buffers.push(buffer);
return 0;
}
/**
* Process and generate a BufferView
* @param {BufferAttribute} attribute
* @param {number} componentType
* @param {number} start
* @param {number} count
* @param {number} target (Optional) Target usage of the BufferView
* @return {Object}
*/
processBufferView(attribute, componentType, start, count, target) {
const json = this.json;
if (!json.bufferViews) json.bufferViews = [];
let componentSize;
switch (componentType) {
case WEBGL_CONSTANTS$1.BYTE:
case WEBGL_CONSTANTS$1.UNSIGNED_BYTE:
componentSize = 1;
break;
case WEBGL_CONSTANTS$1.SHORT:
case WEBGL_CONSTANTS$1.UNSIGNED_SHORT:
componentSize = 2;
break;
default: componentSize = 4;
}
let byteStride = attribute.itemSize * componentSize;
if (target === WEBGL_CONSTANTS$1.ARRAY_BUFFER) byteStride = Math.ceil(byteStride / 4) * 4;
const byteLength = getPaddedBufferSize(count * byteStride);
const dataView = new DataView(new ArrayBuffer(byteLength));
let offset = 0;
for (let i = start; i < start + count; i++) {
for (let a = 0; a < attribute.itemSize; a++) {
let value;
if (attribute.itemSize > 4) value = attribute.array[i * attribute.itemSize + a];
else {
if (a === 0) value = attribute.getX(i);
else if (a === 1) value = attribute.getY(i);
else if (a === 2) value = attribute.getZ(i);
else if (a === 3) value = attribute.getW(i);
if (attribute.normalized === true) value = MathUtils.normalize(value, attribute.array);
}
if (componentType === WEBGL_CONSTANTS$1.FLOAT) dataView.setFloat32(offset, value, true);
else if (componentType === WEBGL_CONSTANTS$1.INT) dataView.setInt32(offset, value, true);
else if (componentType === WEBGL_CONSTANTS$1.UNSIGNED_INT) dataView.setUint32(offset, value, true);
else if (componentType === WEBGL_CONSTANTS$1.SHORT) dataView.setInt16(offset, value, true);
else if (componentType === WEBGL_CONSTANTS$1.UNSIGNED_SHORT) dataView.setUint16(offset, value, true);
else if (componentType === WEBGL_CONSTANTS$1.BYTE) dataView.setInt8(offset, value);
else if (componentType === WEBGL_CONSTANTS$1.UNSIGNED_BYTE) dataView.setUint8(offset, value);
offset += componentSize;
}
if (offset % byteStride !== 0) offset += byteStride - offset % byteStride;
}
const bufferViewDef = {
buffer: this.processBuffer(dataView.buffer),
byteOffset: this.byteOffset,
byteLength
};
if (target !== void 0) bufferViewDef.target = target;
if (target === WEBGL_CONSTANTS$1.ARRAY_BUFFER) bufferViewDef.byteStride = byteStride;
this.byteOffset += byteLength;
json.bufferViews.push(bufferViewDef);
return {
id: json.bufferViews.length - 1,
byteLength: 0
};
}
/**
* Process and generate a BufferView from an image Blob.
* @param {Blob} blob
* @return {Promise}
*/
processBufferViewImage(blob) {
const writer = this;
const json = writer.json;
if (!json.bufferViews) json.bufferViews = [];
return blob.arrayBuffer().then((result) => {
const buffer = getPaddedArrayBuffer(result);
const bufferViewDef = {
buffer: writer.processBuffer(buffer),
byteOffset: writer.byteOffset,
byteLength: buffer.byteLength
};
writer.byteOffset += buffer.byteLength;
return json.bufferViews.push(bufferViewDef) - 1;
});
}
/**
* Process attribute to generate an accessor
* @param {BufferAttribute} attribute Attribute to process
* @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
* @param {Integer} start (Optional)
* @param {Integer} count (Optional)
* @return {Integer|null} Index of the processed accessor on the "accessors" array
*/
processAccessor(attribute, geometry, start, count) {
const json = this.json;
const types = {
1: "SCALAR",
2: "VEC2",
3: "VEC3",
4: "VEC4",
9: "MAT3",
16: "MAT4"
};
let componentType;
if (attribute.array.constructor === Float32Array) componentType = WEBGL_CONSTANTS$1.FLOAT;
else if (attribute.array.constructor === Int32Array) componentType = WEBGL_CONSTANTS$1.INT;
else if (attribute.array.constructor === Uint32Array) componentType = WEBGL_CONSTANTS$1.UNSIGNED_INT;
else if (attribute.array.constructor === Int16Array) componentType = WEBGL_CONSTANTS$1.SHORT;
else if (attribute.array.constructor === Uint16Array) componentType = WEBGL_CONSTANTS$1.UNSIGNED_SHORT;
else if (attribute.array.constructor === Int8Array) componentType = WEBGL_CONSTANTS$1.BYTE;
else if (attribute.array.constructor === Uint8Array) componentType = WEBGL_CONSTANTS$1.UNSIGNED_BYTE;
else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: " + attribute.array.constructor.name);
if (start === void 0) start = 0;
if (count === void 0) count = attribute.count;
if (count === 0) return null;
const minMax = getMinMax(attribute, start, count);
let bufferViewTarget;
if (geometry !== void 0) bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS$1.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS$1.ARRAY_BUFFER;
const bufferView = this.processBufferView(attribute, componentType, start, count, bufferViewTarget);
const accessorDef = {
bufferView: bufferView.id,
byteOffset: bufferView.byteOffset,
componentType,
count,
max: minMax.max,
min: minMax.min,
type: types[attribute.itemSize]
};
if (attribute.normalized === true) accessorDef.normalized = true;
if (!json.accessors) json.accessors = [];
return json.accessors.push(accessorDef) - 1;
}
/**
* Process image
* @param {Image} image to process
* @param {Integer} format of the image (RGBAFormat)
* @param {Boolean} flipY before writing out the image
* @param {String} mimeType export format
* @return {Integer} Index of the processed texture in the "images" array
*/
processImage(image, format, flipY, mimeType = "image/png") {
if (image !== null) {
const writer = this;
const cache = writer.cache;
const json = writer.json;
const options = writer.options;
const pending = writer.pending;
if (!cache.images.has(image)) cache.images.set(image, {});
const cachedImages = cache.images.get(image);
const key = mimeType + ":flipY/" + flipY.toString();
if (cachedImages[key] !== void 0) return cachedImages[key];
if (!json.images) json.images = [];
const imageDef = { mimeType };
const canvas = getCanvas();
canvas.width = Math.min(image.width, options.maxTextureSize);
canvas.height = Math.min(image.height, options.maxTextureSize);
const ctx = canvas.getContext("2d");
if (flipY === true) {
ctx.translate(0, canvas.height);
ctx.scale(1, -1);
}
if (image.data !== void 0) {
if (format !== 1023) console.error("GLTFExporter: Only RGBAFormat is supported.", format);
if (image.width > options.maxTextureSize || image.height > options.maxTextureSize) console.warn("GLTFExporter: Image size is bigger than maxTextureSize", image);
const data = new Uint8ClampedArray(image.height * image.width * 4);
for (let i = 0; i < data.length; i += 4) {
data[i + 0] = image.data[i + 0];
data[i + 1] = image.data[i + 1];
data[i + 2] = image.data[i + 2];
data[i + 3] = image.data[i + 3];
}
ctx.putImageData(new ImageData(data, image.width, image.height), 0, 0);
} else ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
if (options.binary === true) pending.push(getToBlobPromise(canvas, mimeType).then((blob) => writer.processBufferViewImage(blob)).then((bufferViewIndex) => {
imageDef.bufferView = bufferViewIndex;
}));
else if (canvas.toDataURL !== void 0) imageDef.uri = canvas.toDataURL(mimeType);
else pending.push(getToBlobPromise(canvas, mimeType).then(readAsDataURL).then((uri) => {
imageDef.uri = uri;
}));
const index = json.images.push(imageDef) - 1;
cachedImages[key] = index;
return index;
} else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.");
}
/**
* Process sampler
* @param {Texture} map Texture to process
* @return {Integer} Index of the processed texture in the "samplers" array
*/
processSampler(map) {
const json = this.json;
if (!json.samplers) json.samplers = [];
const samplerDef = {
magFilter: THREE_TO_WEBGL[map.magFilter],
minFilter: THREE_TO_WEBGL[map.minFilter],
wrapS: THREE_TO_WEBGL[map.wrapS],
wrapT: THREE_TO_WEBGL[map.wrapT]
};
return json.samplers.push(samplerDef) - 1;
}
/**
* Process texture
* @param {Texture} map Map to process
* @return {Integer} Index of the processed texture in the "textures" array
*/
processTexture(map) {
const options = this.options;
const cache = this.cache;
const json = this.json;
if (cache.textures.has(map)) return cache.textures.get(map);
if (!json.textures) json.textures = [];
if (map instanceof CompressedTexture) map = decompress(map, options.maxTextureSize);
let mimeType = map.userData.mimeType;
if (mimeType === "image/webp") mimeType = "image/png";
const textureDef = {
sampler: this.processSampler(map),
source: this.processImage(map.image, map.format, map.flipY, mimeType)
};
if (map.name) textureDef.name = map.name;
this._invokeAll(function(ext) {
ext.writeTexture && ext.writeTexture(map, textureDef);
});
const index = json.textures.push(textureDef) - 1;
cache.textures.set(map, index);
return index;
}
/**
* Process material
* @param {THREE.Material} material Material to process
* @return {Integer|null} Index of the processed material in the "materials" array
*/
processMaterial(material) {
const cache = this.cache;
const json = this.json;
if (cache.materials.has(material)) return cache.materials.get(material);
if (material.isShaderMaterial) {
console.warn("GLTFExporter: THREE.ShaderMaterial not supported.");
return null;
}
if (!json.materials) json.materials = [];
const materialDef = { pbrMetallicRoughness: {} };
if (material.isMeshStandardMaterial !== true && material.isMeshBasicMaterial !== true) console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");
const color = material.color.toArray().concat([material.opacity]);
if (!equalArray(color, [
1,
1,
1,
1
])) materialDef.pbrMetallicRoughness.baseColorFactor = color;
if (material.isMeshStandardMaterial) {
materialDef.pbrMetallicRoughness.metallicFactor = material.metalness;
materialDef.pbrMetallicRoughness.roughnessFactor = material.roughness;
} else {
materialDef.pbrMetallicRoughness.metallicFactor = .5;
materialDef.pbrMetallicRoughness.roughnessFactor = .5;
}
if (material.metalnessMap || material.roughnessMap) {
const metalRoughTexture = this.buildMetalRoughTexture(material.metalnessMap, material.roughnessMap);
const metalRoughMapDef = {
index: this.processTexture(metalRoughTexture),
channel: metalRoughTexture.channel
};
this.applyTextureTransform(metalRoughMapDef, metalRoughTexture);
materialDef.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
}
if (material.map) {
const baseColorMapDef = {
index: this.processTexture(material.map),
texCoord: material.map.channel
};
this.applyTextureTransform(baseColorMapDef, material.map);
materialDef.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
}
if (material.emissive) {
const emissive = material.emissive;
if (Math.max(emissive.r, emissive.g, emissive.b) > 0) materialDef.emissiveFactor = material.emissive.toArray();
if (material.emissiveMap) {
const emissiveMapDef = {
index: this.processTexture(material.emissiveMap),
texCoord: material.emissiveMap.channel
};
this.applyTextureTransform(emissiveMapDef, material.emissiveMap);
materialDef.emissiveTexture = emissiveMapDef;
}
}
if (material.normalMap) {
const normalMapDef = {
index: this.processTexture(material.normalMap),
texCoord: material.normalMap.channel
};
if (material.normalScale && material.normalScale.x !== 1) normalMapDef.scale = material.normalScale.x;
this.applyTextureTransform(normalMapDef, material.normalMap);
materialDef.normalTexture = normalMapDef;
}
if (material.aoMap) {
const occlusionMapDef = {
index: this.processTexture(material.aoMap),
texCoord: material.aoMap.channel
};
if (material.aoMapIntensity !== 1) occlusionMapDef.strength = material.aoMapIntensity;
this.applyTextureTransform(occlusionMapDef, material.aoMap);
materialDef.occlusionTexture = occlusionMapDef;
}
if (material.transparent) materialDef.alphaMode = "BLEND";
else if (material.alphaTest > 0) {
materialDef.alphaMode = "MASK";
materialDef.alphaCutoff = material.alphaTest;
}
if (material.side === 2) materialDef.doubleSided = true;
if (material.name !== "") materialDef.name = material.name;
this.serializeUserData(material, materialDef);
this._invokeAll(function(ext) {
ext.writeMaterial && ext.writeMaterial(material, materialDef);
});
const index = json.materials.push(materialDef) - 1;
cache.materials.set(material, index);
return index;
}
/**
* Process mesh
* @param {THREE.Mesh} mesh Mesh to process
* @return {Integer|null} Index of the processed mesh in the "meshes" array
*/
processMesh(mesh) {
const cache = this.cache;
const json = this.json;
const meshCacheKeyParts = [mesh.geometry.uuid];
if (Array.isArray(mesh.material)) for (let i = 0, l = mesh.material.length; i < l; i++) meshCacheKeyParts.push(mesh.material[i].uuid);
else meshCacheKeyParts.push(mesh.material.uuid);
const meshCacheKey = meshCacheKeyParts.join(":");
if (cache.meshes.has(meshCacheKey)) return cache.meshes.get(meshCacheKey);
const geometry = mesh.geometry;
let mode;
if (mesh.isLineSegments) mode = WEBGL_CONSTANTS$1.LINES;
else if (mesh.isLineLoop) mode = WEBGL_CONSTANTS$1.LINE_LOOP;
else if (mesh.isLine) mode = WEBGL_CONSTANTS$1.LINE_STRIP;
else if (mesh.isPoints) mode = WEBGL_CONSTANTS$1.POINTS;
else mode = mesh.material.wireframe ? WEBGL_CONSTANTS$1.LINES : WEBGL_CONSTANTS$1.TRIANGLES;
const meshDef = {};
const attributes = {};
const primitives = [];
const targets = [];
const nameConversion = {
...version >= 152 ? {
uv: "TEXCOORD_0",
uv1: "TEXCOORD_1",
uv2: "TEXCOORD_2",
uv3: "TEXCOORD_3"
} : {
uv: "TEXCOORD_0",
uv2: "TEXCOORD_1"
},
color: "COLOR_0",
skinWeight: "WEIGHTS_0",
skinIndex: "JOINTS_0"
};
const originalNormal = geometry.getAttribute("normal");
if (originalNormal !== void 0 && !this.isNormalizedNormalAttribute(originalNormal)) {
console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.");
geometry.setAttribute("normal", this.createNormalizedNormalAttribute(originalNormal));
}
let modifiedAttribute = null;
for (let attributeName in geometry.attributes) {
if (attributeName.slice(0, 5) === "morph") continue;
const attribute = geometry.attributes[attributeName];
attributeName = nameConversion[attributeName] || attributeName.toUpperCase();
if (!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(attributeName)) attributeName = "_" + attributeName;
if (cache.attributes.has(this.getUID(attribute))) {
attributes[attributeName] = cache.attributes.get(this.getUID(attribute));
continue;
}
modifiedAttribute = null;
const array = attribute.array;
if (attributeName === "JOINTS_0" && !(array instanceof Uint16Array) && !(array instanceof Uint8Array)) {
console.warn("GLTFExporter: Attribute \"skinIndex\" converted to type UNSIGNED_SHORT.");
modifiedAttribute = new BufferAttribute(new Uint16Array(array), attribute.itemSize, attribute.normalized);
}
const accessor = this.processAccessor(modifiedAttribute || attribute, geometry);
if (accessor !== null) {
if (!attributeName.startsWith("_")) this.detectMeshQuantization(attributeName, attribute);
attributes[attributeName] = accessor;
cache.attributes.set(this.getUID(attribute), accessor);
}
}
if (originalNormal !== void 0) geometry.setAttribute("normal", originalNormal);
if (Object.keys(attributes).length === 0) return null;
if (mesh.morphTargetInfluences !== void 0 && mesh.morphTargetInfluences.length > 0) {
const weights = [];
const targetNames = [];
const reverseDictionary = {};
if (mesh.morphTargetDictionary !== void 0) for (const key in mesh.morphTargetDictionary) reverseDictionary[mesh.morphTargetDictionary[key]] = key;
for (let i = 0; i < mesh.morphTargetInfluences.length; ++i) {
const target = {};
let warned = false;
for (const attributeName in geometry.morphAttributes) {
if (attributeName !== "position" && attributeName !== "normal") {
if (!warned) {
console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported.");
warned = true;
}
continue;
}
const attribute = geometry.morphAttributes[attributeName][i];
const gltfAttributeName = attributeName.toUpperCase();
const baseAttribute = geometry.attributes[attributeName];
if (cache.attributes.has(this.getUID(attribute, true))) {
target[gltfAttributeName] = cache.attributes.get(this.getUID(attribute, true));
continue;
}
const relativeAttribute = attribute.clone();
if (!geometry.morphTargetsRelative) for (let j = 0, jl = attribute.count; j < jl; j++) for (let a = 0; a < attribute.itemSize; a++) {
if (a === 0) relativeAttribute.setX(j, attribute.getX(j) - baseAttribute.getX(j));
if (a === 1) relativeAttribute.setY(j, attribute.getY(j) - baseAttribute.getY(j));
if (a === 2) relativeAttribute.setZ(j, attribute.getZ(j) - baseAttribute.getZ(j));
if (a === 3) relativeAttribute.setW(j, attribute.getW(j) - baseAttribute.getW(j));
}
target[gltfAttributeName] = this.processAccessor(relativeAttribute, geometry);
cache.attributes.set(this.getUID(baseAttribute, true), target[gltfAttributeName]);
}
targets.push(target);
weights.push(mesh.morphTargetInfluences[i]);
if (mesh.morphTargetDictionary !== void 0) targetNames.push(reverseDictionary[i]);
}
meshDef.weights = weights;
if (targetNames.length > 0) {
meshDef.extras = {};
meshDef.extras.targetNames = targetNames;
}
}
const isMultiMaterial = Array.isArray(mesh.material);
if (isMultiMaterial && geometry.groups.length === 0) return null;
const materials = isMultiMaterial ? mesh.material : [mesh.material];
const groups = isMultiMaterial ? geometry.groups : [{
materialIndex: 0,
start: void 0,
count: void 0
}];
for (let i = 0, il = groups.length; i < il; i++) {
const primitive = {
mode,
attributes
};
this.serializeUserData(geometry, primitive);
if (targets.length > 0) primitive.targets = targets;
if (geometry.index !== null) {
let cacheKey = this.getUID(geometry.index);
if (groups[i].start !== void 0 || groups[i].count !== void 0) cacheKey += ":" + groups[i].start + ":" + groups[i].count;
if (cache.attributes.has(cacheKey)) primitive.indices = cache.attributes.get(cacheKey);
else {
primitive.indices = this.processAccessor(geometry.index, geometry, groups[i].start, groups[i].count);
cache.attributes.set(cacheKey, primitive.indices);
}
if (primitive.indices === null) delete primitive.indices;
}
const material = this.processMaterial(materials[groups[i].materialIndex]);
if (material !== null) primitive.material = material;
primitives.push(primitive);
}
meshDef.primitives = primitives;
if (!json.meshes) json.meshes = [];
this._invokeAll(function(ext) {
ext.writeMesh && ext.writeMesh(mesh, meshDef);
});
const index = json.meshes.push(meshDef) - 1;
cache.meshes.set(meshCacheKey, index);
return index;
}
/**
* If a vertex attribute with a
* [non-standard data type](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview)
* is used, it is checked whether it is a valid data type according to the
* [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md)
* extension.
* In this case the extension is automatically added to the list of used extensions.
*
* @param {string} attributeName
* @param {THREE.BufferAttribute} attribute
*/
detectMeshQuantization(attributeName, attribute) {
if (this.extensionsUsed[KHR_MESH_QUANTIZATION]) return;
let attrType = void 0;
switch (attribute.array.constructor) {
case Int8Array:
attrType = "byte";
break;
case Uint8Array:
attrType = "unsigned byte";
break;
case Int16Array:
attrType = "short";
break;
case Uint16Array:
attrType = "unsigned short";
break;
default: return;
}
if (attribute.normalized) attrType += " normalized";
const attrNamePrefix = attributeName.split("_", 1)[0];
if (KHR_mesh_quantization_ExtraAttrTypes[attrNamePrefix] && KHR_mesh_quantization_ExtraAttrTypes[attrNamePrefix].includes(attrType)) {
this.extensionsUsed[KHR_MESH_QUANTIZATION] = true;
this.extensionsRequired[KHR_MESH_QUANTIZATION] = true;
}
}
/**
* Process camera
* @param {THREE.Camera} camera Camera to process
* @return {Integer} Index of the processed mesh in the "camera" array
*/
processCamera(camera) {
const json = this.json;
if (!json.cameras) json.cameras = [];
const isOrtho = camera.isOrthographicCamera;
const cameraDef = { type: isOrtho ? "orthographic" : "perspective" };
if (isOrtho) cameraDef.orthographic = {
xmag: camera.right * 2,
ymag: camera.top * 2,
zfar: camera.far <= 0 ? .001 : camera.far,
znear: camera.near < 0 ? 0 : camera.near
};
else cameraDef.perspective = {
aspectRatio: camera.aspect,
yfov: MathUtils.degToRad(camera.fov),
zfar: camera.far <= 0 ? .001 : camera.far,
znear: camera.near < 0 ? 0 : camera.near
};
if (camera.name !== "") cameraDef.name = camera.type;
return json.cameras.push(cameraDef) - 1;
}
/**
* Creates glTF animation entry from AnimationClip object.
*
* Status:
* - Only properties listed in PATH_PROPERTIES may be animated.
*
* @param {THREE.AnimationClip} clip
* @param {THREE.Object3D} root
* @return {number|null}
*/
processAnimation(clip, root) {
const json = this.json;
const nodeMap = this.nodeMap;
if (!json.animations) json.animations = [];
clip = GLTFExporter.Utils.mergeMorphTargetTracks(clip.clone(), root);
const tracks = clip.tracks;
const channels = [];
const samplers = [];
for (let i = 0; i < tracks.length; ++i) {
const track = tracks[i];
const trackBinding = PropertyBinding.parseTrackName(track.name);
let trackNode = PropertyBinding.findNode(root, trackBinding.nodeName);
const trackProperty = PATH_PROPERTIES$1[trackBinding.propertyName];
if (trackBinding.objectName === "bones") if (trackNode.isSkinnedMesh === true) trackNode = trackNode.skeleton.getBoneByName(trackBinding.objectIndex);
else trackNode = void 0;
if (!trackNode || !trackProperty) {
console.warn("THREE.GLTFExporter: Could not export animation track \"%s\".", track.name);
return null;
}
const inputItemSize = 1;
let outputItemSize = track.values.length / track.times.length;
if (trackProperty === PATH_PROPERTIES$1.morphTargetInfluences) outputItemSize /= trackNode.morphTargetInfluences.length;
let interpolation;
if (track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true) {
interpolation = "CUBICSPLINE";
outputItemSize /= 3;
} else if (track.getInterpolation() === 2300) interpolation = "STEP";
else interpolation = "LINEAR";
samplers.push({
input: this.processAccessor(new BufferAttribute(track.times, inputItemSize)),
output: this.processAccessor(new BufferAttribute(track.values, outputItemSize)),
interpolation
});
channels.push({
sampler: samplers.length - 1,
target: {
node: nodeMap.get(trackNode),
path: trackProperty
}
});
}
json.animations.push({
name: clip.name || "clip_" + json.animations.length,
samplers,
channels
});
return json.animations.length - 1;
}
/**
* @param {THREE.Object3D} object
* @return {number|null}
*/
processSkin(object) {
const json = this.json;
const nodeMap = this.nodeMap;
const node = json.nodes[nodeMap.get(object)];
const skeleton = object.skeleton;
if (skeleton === void 0) return null;
const rootJoint = object.skeleton.bones[0];
if (rootJoint === void 0) return null;
const joints = [];
const inverseBindMatrices = new Float32Array(skeleton.bones.length * 16);
const temporaryBoneInverse = new Matrix4();
for (let i = 0; i < skeleton.bones.length; ++i) {
joints.push(nodeMap.get(skeleton.bones[i]));
temporaryBoneInverse.copy(skeleton.boneInverses[i]);
temporaryBoneInverse.multiply(object.bindMatrix).toArray(inverseBindMatrices, i * 16);
}
if (json.skins === void 0) json.skins = [];
json.skins.push({
inverseBindMatrices: this.processAccessor(new BufferAttribute(inverseBindMatrices, 16)),
joints,
skeleton: nodeMap.get(rootJoint)
});
return node.skin = json.skins.length - 1;
}
/**
* Process Object3D node
* @param {THREE.Object3D} node Object3D to processNode
* @return {Integer} Index of the node in the nodes list
*/
processNode(object) {
const json = this.json;
const options = this.options;
const nodeMap = this.nodeMap;
if (!json.nodes) json.nodes = [];
const nodeDef = {};
if (options.trs) {
const rotation = object.quaternion.toArray();
const position = object.position.toArray();
const scale = object.scale.toArray();
if (!equalArray(rotation, [
0,
0,
0,
1
])) nodeDef.rotation = rotation;
if (!equalArray(position, [
0,
0,
0
])) nodeDef.translation = position;
if (!equalArray(scale, [
1,
1,
1
])) nodeDef.scale = scale;
} else {
if (object.matrixAutoUpdate) object.updateMatrix();
if (isIdentityMatrix(object.matrix) === false) nodeDef.matrix = object.matrix.elements;
}
if (object.name !== "") nodeDef.name = String(object.name);
this.serializeUserData(object, nodeDef);
if (object.isMesh || object.isLine || object.isPoints) {
const meshIndex = this.processMesh(object);
if (meshIndex !== null) nodeDef.mesh = meshIndex;
} else if (object.isCamera) nodeDef.camera = this.processCamera(object);
if (object.isSkinnedMesh) this.skins.push(object);
if (object.children.length > 0) {
const children = [];
for (let i = 0, l = object.children.length; i < l; i++) {
const child = object.children[i];
if (child.visible || options.onlyVisible === false) {
const nodeIndex2 = this.processNode(child);
if (nodeIndex2 !== null) children.push(nodeIndex2);
}
}
if (children.length > 0) nodeDef.children = children;
}
this._invokeAll(function(ext) {
ext.writeNode && ext.writeNode(object, nodeDef);
});
const nodeIndex = json.nodes.push(nodeDef) - 1;
nodeMap.set(object, nodeIndex);
return nodeIndex;
}
/**
* Process Scene
* @param {Scene} node Scene to process
*/
processScene(scene) {
const json = this.json;
const options = this.options;
if (!json.scenes) {
json.scenes = [];
json.scene = 0;
}
const sceneDef = {};
if (scene.name !== "") sceneDef.name = scene.name;
json.scenes.push(sceneDef);
const nodes = [];
for (let i = 0, l = scene.children.length; i < l; i++) {
const child = scene.children[i];
if (child.visible || options.onlyVisible === false) {
const nodeIndex = this.processNode(child);
if (nodeIndex !== null) nodes.push(nodeIndex);
}
}
if (nodes.length > 0) sceneDef.nodes = nodes;
this.serializeUserData(scene, sceneDef);
}
/**
* Creates a Scene to hold a list of objects and parse it
* @param {Array} objects List of objects to process
*/
processObjects(objects) {
const scene = new Scene();
scene.name = "AuxScene";
for (let i = 0; i < objects.length; i++) scene.children.push(objects[i]);
this.processScene(scene);
}
/**
* @param {THREE.Object3D|Array} input
*/
processInput(input) {
const options = this.options;
input = input instanceof Array ? input : [input];
this._invokeAll(function(ext) {
ext.beforeParse && ext.beforeParse(input);
});
const objectsWithoutScene = [];
for (let i = 0; i < input.length; i++) if (input[i] instanceof Scene) this.processScene(input[i]);
else objectsWithoutScene.push(input[i]);
if (objectsWithoutScene.length > 0) this.processObjects(objectsWithoutScene);
for (let i = 0; i < this.skins.length; ++i) this.processSkin(this.skins[i]);
for (let i = 0; i < options.animations.length; ++i) this.processAnimation(options.animations[i], input[0]);
this._invokeAll(function(ext) {
ext.afterParse && ext.afterParse(input);
});
}
_invokeAll(func) {
for (let i = 0, il = this.plugins.length; i < il; i++) func(this.plugins[i]);
}
};
var GLTFLightExtension = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_lights_punctual";
}
writeNode(light, nodeDef) {
if (!light.isLight) return;
if (!light.isDirectionalLight && !light.isPointLight && !light.isSpotLight) {
console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.", light);
return;
}
const writer = this.writer;
const json = writer.json;
const extensionsUsed = writer.extensionsUsed;
const lightDef = {};
if (light.name) lightDef.name = light.name;
lightDef.color = light.color.toArray();
lightDef.intensity = light.intensity;
if (light.isDirectionalLight) lightDef.type = "directional";
else if (light.isPointLight) {
lightDef.type = "point";
if (light.distance > 0) lightDef.range = light.distance;
} else if (light.isSpotLight) {
lightDef.type = "spot";
if (light.distance > 0) lightDef.range = light.distance;
lightDef.spot = {};
lightDef.spot.innerConeAngle = (light.penumbra - 1) * light.angle * -1;
lightDef.spot.outerConeAngle = light.angle;
}
if (light.decay !== void 0 && light.decay !== 2) console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.");
if (light.target && (light.target.parent !== light || light.target.position.x !== 0 || light.target.position.y !== 0 || light.target.position.z !== -1)) console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.");
if (!extensionsUsed[this.name]) {
json.extensions = json.extensions || {};
json.extensions[this.name] = { lights: [] };
extensionsUsed[this.name] = true;
}
const lights = json.extensions[this.name].lights;
lights.push(lightDef);
nodeDef.extensions = nodeDef.extensions || {};
nodeDef.extensions[this.name] = { light: lights.length - 1 };
}
};
var GLTFMaterialsUnlitExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_unlit";
}
writeMaterial(material, materialDef) {
if (!material.isMeshBasicMaterial) return;
const extensionsUsed = this.writer.extensionsUsed;
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = {};
extensionsUsed[this.name] = true;
materialDef.pbrMetallicRoughness.metallicFactor = 0;
materialDef.pbrMetallicRoughness.roughnessFactor = .9;
}
};
var GLTFMaterialsClearcoatExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_clearcoat";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.clearcoat === 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
extensionDef.clearcoatFactor = material.clearcoat;
if (material.clearcoatMap) {
const clearcoatMapDef = {
index: writer.processTexture(material.clearcoatMap),
texCoord: material.clearcoatMap.channel
};
writer.applyTextureTransform(clearcoatMapDef, material.clearcoatMap);
extensionDef.clearcoatTexture = clearcoatMapDef;
}
extensionDef.clearcoatRoughnessFactor = material.clearcoatRoughness;
if (material.clearcoatRoughnessMap) {
const clearcoatRoughnessMapDef = {
index: writer.processTexture(material.clearcoatRoughnessMap),
texCoord: material.clearcoatRoughnessMap.channel
};
writer.applyTextureTransform(clearcoatRoughnessMapDef, material.clearcoatRoughnessMap);
extensionDef.clearcoatRoughnessTexture = clearcoatRoughnessMapDef;
}
if (material.clearcoatNormalMap) {
const clearcoatNormalMapDef = {
index: writer.processTexture(material.clearcoatNormalMap),
texCoord: material.clearcoatNormalMap.channel
};
writer.applyTextureTransform(clearcoatNormalMapDef, material.clearcoatNormalMap);
extensionDef.clearcoatNormalTexture = clearcoatNormalMapDef;
}
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsIridescenceExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_iridescence";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.iridescence === 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
extensionDef.iridescenceFactor = material.iridescence;
if (material.iridescenceMap) {
const iridescenceMapDef = {
index: writer.processTexture(material.iridescenceMap),
texCoord: material.iridescenceMap.channel
};
writer.applyTextureTransform(iridescenceMapDef, material.iridescenceMap);
extensionDef.iridescenceTexture = iridescenceMapDef;
}
extensionDef.iridescenceIor = material.iridescenceIOR;
extensionDef.iridescenceThicknessMinimum = material.iridescenceThicknessRange[0];
extensionDef.iridescenceThicknessMaximum = material.iridescenceThicknessRange[1];
if (material.iridescenceThicknessMap) {
const iridescenceThicknessMapDef = {
index: writer.processTexture(material.iridescenceThicknessMap),
texCoord: material.iridescenceThicknessMap.channel
};
writer.applyTextureTransform(iridescenceThicknessMapDef, material.iridescenceThicknessMap);
extensionDef.iridescenceThicknessTexture = iridescenceThicknessMapDef;
}
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsTransmissionExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_transmission";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.transmission === 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
extensionDef.transmissionFactor = material.transmission;
if (material.transmissionMap) {
const transmissionMapDef = {
index: writer.processTexture(material.transmissionMap),
texCoord: material.transmissionMap.channel
};
writer.applyTextureTransform(transmissionMapDef, material.transmissionMap);
extensionDef.transmissionTexture = transmissionMapDef;
}
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsVolumeExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_volume";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.transmission === 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
extensionDef.thicknessFactor = material.thickness;
if (material.thicknessMap) {
const thicknessMapDef = {
index: writer.processTexture(material.thicknessMap),
texCoord: material.thicknessMap.channel
};
writer.applyTextureTransform(thicknessMapDef, material.thicknessMap);
extensionDef.thicknessTexture = thicknessMapDef;
}
extensionDef.attenuationDistance = material.attenuationDistance;
extensionDef.attenuationColor = material.attenuationColor.toArray();
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsIorExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_ior";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.ior === 1.5) return;
const extensionsUsed = this.writer.extensionsUsed;
const extensionDef = {};
extensionDef.ior = material.ior;
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsSpecularExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_specular";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.specularIntensity === 1 && material.specularColor.equals(DEFAULT_SPECULAR_COLOR) && !material.specularIntensityMap && !material.specularColorTexture) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
if (material.specularIntensityMap) {
const specularIntensityMapDef = {
index: writer.processTexture(material.specularIntensityMap),
texCoord: material.specularIntensityMap.channel
};
writer.applyTextureTransform(specularIntensityMapDef, material.specularIntensityMap);
extensionDef.specularTexture = specularIntensityMapDef;
}
if (material.specularColorMap) {
const specularColorMapDef = {
index: writer.processTexture(material.specularColorMap),
texCoord: material.specularColorMap.channel
};
writer.applyTextureTransform(specularColorMapDef, material.specularColorMap);
extensionDef.specularColorTexture = specularColorMapDef;
}
extensionDef.specularFactor = material.specularIntensity;
extensionDef.specularColorFactor = material.specularColor.toArray();
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsSheenExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_sheen";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.sheen == 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
if (material.sheenRoughnessMap) {
const sheenRoughnessMapDef = {
index: writer.processTexture(material.sheenRoughnessMap),
texCoord: material.sheenRoughnessMap.channel
};
writer.applyTextureTransform(sheenRoughnessMapDef, material.sheenRoughnessMap);
extensionDef.sheenRoughnessTexture = sheenRoughnessMapDef;
}
if (material.sheenColorMap) {
const sheenColorMapDef = {
index: writer.processTexture(material.sheenColorMap),
texCoord: material.sheenColorMap.channel
};
writer.applyTextureTransform(sheenColorMapDef, material.sheenColorMap);
extensionDef.sheenColorTexture = sheenColorMapDef;
}
extensionDef.sheenRoughnessFactor = material.sheenRoughness;
extensionDef.sheenColorFactor = material.sheenColor.toArray();
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsAnisotropyExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_anisotropy";
}
writeMaterial(material, materialDef) {
if (!material.isMeshPhysicalMaterial || material.anisotropy == 0) return;
const writer = this.writer;
const extensionsUsed = writer.extensionsUsed;
const extensionDef = {};
if (material.anisotropyMap) {
const anisotropyMapDef = { index: writer.processTexture(material.anisotropyMap) };
writer.applyTextureTransform(anisotropyMapDef, material.anisotropyMap);
extensionDef.anisotropyTexture = anisotropyMapDef;
}
extensionDef.anisotropyStrength = material.anisotropy;
extensionDef.anisotropyRotation = material.anisotropyRotation;
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
var GLTFMaterialsEmissiveStrengthExtension$1 = class {
constructor(writer) {
this.writer = writer;
this.name = "KHR_materials_emissive_strength";
}
writeMaterial(material, materialDef) {
if (!material.isMeshStandardMaterial || material.emissiveIntensity === 1) return;
const extensionsUsed = this.writer.extensionsUsed;
const extensionDef = {};
extensionDef.emissiveStrength = material.emissiveIntensity;
materialDef.extensions = materialDef.extensions || {};
materialDef.extensions[this.name] = extensionDef;
extensionsUsed[this.name] = true;
}
};
//#endregion
//#region node_modules/three-stdlib/node_modules/fflate/esm/browser.js
var u8 = Uint8Array, u16 = Uint16Array, u32 = Uint32Array;
var fleb = new u8([
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
4,
4,
4,
4,
5,
5,
5,
5,
0,
0,
0,
0
]);
var fdeb = new u8([
0,
0,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
5,
5,
6,
6,
7,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
13,
13,
0,
0
]);
var clim = new u8([
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
]);
var freb = function(eb, start) {
var b = new u16(31);
for (var i = 0; i < 31; ++i) b[i] = start += 1 << eb[i - 1];
var r = new u32(b[30]);
for (var i = 1; i < 30; ++i) for (var j = b[i]; j < b[i + 1]; ++j) r[j] = j - b[i] << 5 | i;
return [b, r];
};
var _a = freb(fleb, 2), fl = _a[0], revfl = _a[1];
fl[28] = 258, revfl[258] = 28;
var _b = freb(fdeb, 0), fd = _b[0], revfd = _b[1];
var rev = new u16(32768);
for (var i$1 = 0; i$1 < 32768; ++i$1) {
var x = (i$1 & 43690) >>> 1 | (i$1 & 21845) << 1;
x = (x & 52428) >>> 2 | (x & 13107) << 2;
x = (x & 61680) >>> 4 | (x & 3855) << 4;
rev[i$1] = ((x & 65280) >>> 8 | (x & 255) << 8) >>> 1;
}
var hMap = (function(cd, mb, r) {
var s = cd.length;
var i = 0;
var l = new u16(mb);
for (; i < s; ++i) ++l[cd[i] - 1];
var le = new u16(mb);
for (i = 0; i < mb; ++i) le[i] = le[i - 1] + l[i - 1] << 1;
var co;
if (r) {
co = new u16(1 << mb);
var rvb = 15 - mb;
for (i = 0; i < s; ++i) if (cd[i]) {
var sv = i << 4 | cd[i];
var r_1 = mb - cd[i];
var v = le[cd[i] - 1]++ << r_1;
for (var m = v | (1 << r_1) - 1; v <= m; ++v) co[rev[v] >>> rvb] = sv;
}
} else {
co = new u16(s);
for (i = 0; i < s; ++i) if (cd[i]) co[i] = rev[le[cd[i] - 1]++] >>> 15 - cd[i];
}
return co;
});
var flt = new u8(288);
for (var i$1 = 0; i$1 < 144; ++i$1) flt[i$1] = 8;
for (var i$1 = 144; i$1 < 256; ++i$1) flt[i$1] = 9;
for (var i$1 = 256; i$1 < 280; ++i$1) flt[i$1] = 7;
for (var i$1 = 280; i$1 < 288; ++i$1) flt[i$1] = 8;
var fdt = new u8(32);
for (var i$1 = 0; i$1 < 32; ++i$1) fdt[i$1] = 5;
var flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);
var fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);
var max = function(a) {
var m = a[0];
for (var i = 1; i < a.length; ++i) if (a[i] > m) m = a[i];
return m;
};
var bits = function(d, p, m) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
};
var bits16 = function(d, p) {
var o = p / 8 | 0;
return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
};
var shft = function(p) {
return (p / 8 | 0) + (p & 7 && 1);
};
var slc = function(v, s, e) {
if (s == null || s < 0) s = 0;
if (e == null || e > v.length) e = v.length;
var n = new (v instanceof u16 ? u16 : v instanceof u32 ? u32 : u8)(e - s);
n.set(v.subarray(s, e));
return n;
};
var inflt = function(dat, buf, st) {
var sl = dat.length;
if (!sl || st && !st.l && sl < 5) return buf || new u8(0);
var noBuf = !buf || st;
var noSt = !st || st.i;
if (!st) st = {};
if (!buf) buf = new u8(sl * 3);
var cbuf = function(l) {
var bl = buf.length;
if (l > bl) {
var nbuf = new u8(Math.max(bl * 2, l));
nbuf.set(buf);
buf = nbuf;
}
};
var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;
var tbts = sl * 8;
do {
if (!lm) {
st.f = final = bits(dat, pos, 1);
var type = bits(dat, pos + 1, 3);
pos += 3;
if (!type) {
var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
if (t > sl) {
if (noSt) throw "unexpected EOF";
break;
}
if (noBuf) cbuf(bt + l);
buf.set(dat.subarray(s, t), bt);
st.b = bt += l, st.p = pos = t * 8;
continue;
} else if (type == 1) lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
else if (type == 2) {
var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
var tl = hLit + bits(dat, pos + 5, 31) + 1;
pos += 14;
var ldt = new u8(tl);
var clt = new u8(19);
for (var i = 0; i < hcLen; ++i) clt[clim[i]] = bits(dat, pos + i * 3, 7);
pos += hcLen * 3;
var clb = max(clt), clbmsk = (1 << clb) - 1;
var clm = hMap(clt, clb, 1);
for (var i = 0; i < tl;) {
var r = clm[bits(dat, pos, clbmsk)];
pos += r & 15;
var s = r >>> 4;
if (s < 16) ldt[i++] = s;
else {
var c = 0, n = 0;
if (s == 16) n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
else if (s == 17) n = 3 + bits(dat, pos, 7), pos += 3;
else if (s == 18) n = 11 + bits(dat, pos, 127), pos += 7;
while (n--) ldt[i++] = c;
}
}
var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
lbt = max(lt);
dbt = max(dt);
lm = hMap(lt, lbt, 1);
dm = hMap(dt, dbt, 1);
} else throw "invalid block type";
if (pos > tbts) {
if (noSt) throw "unexpected EOF";
break;
}
}
if (noBuf) cbuf(bt + 131072);
var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
var lpos = pos;
for (;; lpos = pos) {
var c = lm[bits16(dat, pos) & lms], sym = c >>> 4;
pos += c & 15;
if (pos > tbts) {
if (noSt) throw "unexpected EOF";
break;
}
if (!c) throw "invalid length/literal";
if (sym < 256) buf[bt++] = sym;
else if (sym == 256) {
lpos = pos, lm = null;
break;
} else {
var add = sym - 254;
if (sym > 264) {
var i = sym - 257, b = fleb[i];
add = bits(dat, pos, (1 << b) - 1) + fl[i];
pos += b;
}
var d = dm[bits16(dat, pos) & dms], dsym = d >>> 4;
if (!d) throw "invalid distance";
pos += d & 15;
var dt = fd[dsym];
if (dsym > 3) {
var b = fdeb[dsym];
dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
}
if (pos > tbts) {
if (noSt) throw "unexpected EOF";
break;
}
if (noBuf) cbuf(bt + 131072);
var end = bt + add;
for (; bt < end; bt += 4) {
buf[bt] = buf[bt - dt];
buf[bt + 1] = buf[bt + 1 - dt];
buf[bt + 2] = buf[bt + 2 - dt];
buf[bt + 3] = buf[bt + 3 - dt];
}
bt = end;
}
}
st.l = lm, st.p = lpos, st.b = bt;
if (lm) final = 1, st.m = lbt, st.d = dm, st.n = dbt;
} while (!final);
return bt == buf.length ? buf : slc(buf, 0, bt);
};
var wbits = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >>> 8;
};
var wbits16 = function(d, p, v) {
v <<= p & 7;
var o = p / 8 | 0;
d[o] |= v;
d[o + 1] |= v >>> 8;
d[o + 2] |= v >>> 16;
};
var hTree = function(d, mb) {
var t = [];
for (var i = 0; i < d.length; ++i) if (d[i]) t.push({
s: i,
f: d[i]
});
var s = t.length;
var t2 = t.slice();
if (!s) return [et, 0];
if (s == 1) {
var v = new u8(t[0].s + 1);
v[t[0].s] = 1;
return [v, 1];
}
t.sort(function(a, b) {
return a.f - b.f;
});
t.push({
s: -1,
f: 25001
});
var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;
t[0] = {
s: -1,
f: l.f + r.f,
l,
r
};
while (i1 != s - 1) {
l = t[t[i0].f < t[i2].f ? i0++ : i2++];
r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];
t[i1++] = {
s: -1,
f: l.f + r.f,
l,
r
};
}
var maxSym = t2[0].s;
for (var i = 1; i < s; ++i) if (t2[i].s > maxSym) maxSym = t2[i].s;
var tr = new u16(maxSym + 1);
var mbt = ln(t[i1 - 1], tr, 0);
if (mbt > mb) {
var i = 0, dt = 0;
var lft = mbt - mb, cst = 1 << lft;
t2.sort(function(a, b) {
return tr[b.s] - tr[a.s] || a.f - b.f;
});
for (; i < s; ++i) {
var i2_1 = t2[i].s;
if (tr[i2_1] > mb) {
dt += cst - (1 << mbt - tr[i2_1]);
tr[i2_1] = mb;
} else break;
}
dt >>>= lft;
while (dt > 0) {
var i2_2 = t2[i].s;
if (tr[i2_2] < mb) dt -= 1 << mb - tr[i2_2]++ - 1;
else ++i;
}
for (; i >= 0 && dt; --i) {
var i2_3 = t2[i].s;
if (tr[i2_3] == mb) {
--tr[i2_3];
++dt;
}
}
mbt = mb;
}
return [new u8(tr), mbt];
};
var ln = function(n, l, d) {
return n.s == -1 ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) : l[n.s] = d;
};
var lc = function(c) {
var s = c.length;
while (s && !c[--s]);
var cl = new u16(++s);
var cli = 0, cln = c[0], cls = 1;
var w = function(v) {
cl[cli++] = v;
};
for (var i = 1; i <= s; ++i) if (c[i] == cln && i != s) ++cls;
else {
if (!cln && cls > 2) {
for (; cls > 138; cls -= 138) w(32754);
if (cls > 2) {
w(cls > 10 ? cls - 11 << 5 | 28690 : cls - 3 << 5 | 12305);
cls = 0;
}
} else if (cls > 3) {
w(cln), --cls;
for (; cls > 6; cls -= 6) w(8304);
if (cls > 2) w(cls - 3 << 5 | 8208), cls = 0;
}
while (cls--) w(cln);
cls = 1;
cln = c[i];
}
return [cl.subarray(0, cli), s];
};
var clen = function(cf, cl) {
var l = 0;
for (var i = 0; i < cl.length; ++i) l += cf[i] * cl[i];
return l;
};
var wfblk = function(out, pos, dat) {
var s = dat.length;
var o = shft(pos + 2);
out[o] = s & 255;
out[o + 1] = s >>> 8;
out[o + 2] = out[o] ^ 255;
out[o + 3] = out[o + 1] ^ 255;
for (var i = 0; i < s; ++i) out[o + i + 4] = dat[i];
return (o + 4 + s) * 8;
};
var wblk = function(dat, out, final, syms, lf, df, eb, li, bs, bl, p) {
wbits(out, p++, final);
++lf[256];
var _a = hTree(lf, 15), dlt = _a[0], mlb = _a[1];
var _b = hTree(df, 15), ddt = _b[0], mdb = _b[1];
var _c = lc(dlt), lclt = _c[0], nlc = _c[1];
var _d = lc(ddt), lcdt = _d[0], ndc = _d[1];
var lcfreq = new u16(19);
for (var i = 0; i < lclt.length; ++i) lcfreq[lclt[i] & 31]++;
for (var i = 0; i < lcdt.length; ++i) lcfreq[lcdt[i] & 31]++;
var _e = hTree(lcfreq, 7), lct = _e[0], mlcb = _e[1];
var nlcc = 19;
for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc);
var flen = bl + 5 << 3;
var ftlen = clen(lf, flt) + clen(df, fdt) + eb;
var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + (2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]);
if (flen <= ftlen && flen <= dtlen) return wfblk(out, p, dat.subarray(bs, bs + bl));
var lm, ll, dm, dl;
wbits(out, p, 1 + (dtlen < ftlen)), p += 2;
if (dtlen < ftlen) {
lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;
var llm = hMap(lct, mlcb, 0);
wbits(out, p, nlc - 257);
wbits(out, p + 5, ndc - 1);
wbits(out, p + 10, nlcc - 4);
p += 14;
for (var i = 0; i < nlcc; ++i) wbits(out, p + 3 * i, lct[clim[i]]);
p += 3 * nlcc;
var lcts = [lclt, lcdt];
for (var it = 0; it < 2; ++it) {
var clct = lcts[it];
for (var i = 0; i < clct.length; ++i) {
var len = clct[i] & 31;
wbits(out, p, llm[len]), p += lct[len];
if (len > 15) wbits(out, p, clct[i] >>> 5 & 127), p += clct[i] >>> 12;
}
}
} else lm = flm, ll = flt, dm = fdm, dl = fdt;
for (var i = 0; i < li; ++i) if (syms[i] > 255) {
var len = syms[i] >>> 18 & 31;
wbits16(out, p, lm[len + 257]), p += ll[len + 257];
if (len > 7) wbits(out, p, syms[i] >>> 23 & 31), p += fleb[len];
var dst = syms[i] & 31;
wbits16(out, p, dm[dst]), p += dl[dst];
if (dst > 3) wbits16(out, p, syms[i] >>> 5 & 8191), p += fdeb[dst];
} else wbits16(out, p, lm[syms[i]]), p += ll[syms[i]];
wbits16(out, p, lm[256]);
return p + ll[256];
};
var deo = /*#__PURE__*/ new u32([
65540,
131080,
131088,
131104,
262176,
1048704,
1048832,
2114560,
2117632
]);
var et = /*#__PURE__*/ new u8(0);
var dflt = function(dat, lvl, plvl, pre, post, lst) {
var s = dat.length;
var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7e3)) + post);
var w = o.subarray(pre, o.length - post);
var pos = 0;
if (!lvl || s < 8) for (var i = 0; i <= s; i += 65535) {
var e = i + 65535;
if (e < s) pos = wfblk(w, pos, dat.subarray(i, e));
else {
w[i] = lst;
pos = wfblk(w, pos, dat.subarray(i, s));
}
}
else {
var opt = deo[lvl - 1];
var n = opt >>> 13, c = opt & 8191;
var msk_1 = (1 << plvl) - 1;
var prev = new u16(32768), head = new u16(msk_1 + 1);
var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;
var hsh = function(i) {
return (dat[i] ^ dat[i + 1] << bs1_1 ^ dat[i + 2] << bs2_1) & msk_1;
};
var syms = new u32(25e3);
var lf = new u16(288), df = new u16(32);
var lc_1 = 0, eb = 0, i = 0, li = 0, wi = 0, bs = 0;
for (; i < s; ++i) {
var hv = hsh(i);
var imod = i & 32767, pimod = head[hv];
prev[imod] = pimod;
head[hv] = imod;
if (wi <= i) {
var rem = s - i;
if ((lc_1 > 7e3 || li > 24576) && rem > 423) {
pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);
li = lc_1 = eb = 0, bs = i;
for (var j = 0; j < 286; ++j) lf[j] = 0;
for (var j = 0; j < 30; ++j) df[j] = 0;
}
var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;
if (rem > 2 && hv == hsh(i - dif)) {
var maxn = Math.min(n, rem) - 1;
var maxd = Math.min(32767, i);
var ml = Math.min(258, rem);
while (dif <= maxd && --ch_1 && imod != pimod) {
if (dat[i + l] == dat[i + l - dif]) {
var nl = 0;
for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl);
if (nl > l) {
l = nl, d = dif;
if (nl > maxn) break;
var mmd = Math.min(dif, nl - 2);
var md = 0;
for (var j = 0; j < mmd; ++j) {
var ti = i - dif + j + 32768 & 32767;
var cd = ti - prev[ti] + 32768 & 32767;
if (cd > md) md = cd, pimod = ti;
}
}
}
imod = pimod, pimod = prev[imod];
dif += imod - pimod + 32768 & 32767;
}
}
if (d) {
syms[li++] = 268435456 | revfl[l] << 18 | revfd[d];
var lin = revfl[l] & 31, din = revfd[d] & 31;
eb += fleb[lin] + fdeb[din];
++lf[257 + lin];
++df[din];
wi = i + l;
++lc_1;
} else {
syms[li++] = dat[i];
++lf[dat[i]];
}
}
}
pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);
if (!lst && pos & 7) pos = wfblk(w, pos + 1, et);
}
return slc(o, 0, pre + shft(pos) + post);
};
var crct = /*#__PURE__*/ (function() {
var t = new Int32Array(256);
for (var i = 0; i < 256; ++i) {
var c = i, k = 9;
while (--k) c = (c & 1 && -306674912) ^ c >>> 1;
t[i] = c;
}
return t;
})();
var crc = function() {
var c = -1;
return {
p: function(d) {
var cr = c;
for (var i = 0; i < d.length; ++i) cr = crct[cr & 255 ^ d[i]] ^ cr >>> 8;
c = cr;
},
d: function() {
return ~c;
}
};
};
var dopt = function(dat, opt, pre, post, st) {
return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 12 + opt.mem, pre, post, !st);
};
var mrg = function(a, b) {
var o = {};
for (var k in a) o[k] = a[k];
for (var k in b) o[k] = b[k];
return o;
};
var b2 = function(d, b) {
return d[b] | d[b + 1] << 8;
};
var b4 = function(d, b) {
return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
};
var b8 = function(d, b) {
return b4(d, b) + b4(d, b + 4) * 4294967296;
};
var wbytes = function(d, b, v) {
for (; v; ++b) d[b] = v, v >>>= 8;
};
var gzs = function(d) {
if (d[0] != 31 || d[1] != 139 || d[2] != 8) throw "invalid gzip data";
var flg = d[3];
var st = 10;
if (flg & 4) st += d[10] | (d[11] << 8) + 2;
for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++]);
return st + (flg & 2);
};
var gzl = function(d) {
var l = d.length;
return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;
};
var zlv = function(d) {
if ((d[0] & 15) != 8 || d[0] >>> 4 > 7 || (d[0] << 8 | d[1]) % 31) throw "invalid zlib data";
if (d[1] & 32) throw "invalid zlib data: preset dictionaries not supported";
};
/**
* Compresses data with DEFLATE without any wrapper
* @param data The data to compress
* @param opts The compression options
* @returns The deflated version of the data
*/
function deflateSync(data, opts) {
return dopt(data, opts || {}, 0, 0);
}
/**
* Expands DEFLATE data with no wrapper
* @param data The data to decompress
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
* @returns The decompressed version of the data
*/
function inflateSync(data, out) {
return inflt(data, out);
}
/**
* Expands GZIP data
* @param data The data to decompress
* @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
* @returns The decompressed version of the data
*/
function gunzipSync(data, out) {
return inflt(data.subarray(gzs(data), -8), out || new u8(gzl(data)));
}
/**
* Expands Zlib data
* @param data The data to decompress
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
* @returns The decompressed version of the data
*/
function unzlibSync(data, out) {
return inflt((zlv(data), data.subarray(2, -4)), out);
}
var fltn = function(d, p, t, o) {
for (var k in d) {
var val = d[k], n = p + k;
if (val instanceof u8) t[n] = [val, o];
else if (Array.isArray(val)) t[n] = [val[0], mrg(o, val[1])];
else fltn(val, n + "/", t, o);
}
};
var te = typeof TextEncoder != "undefined" && /*#__PURE__*/ new TextEncoder();
var td = typeof TextDecoder != "undefined" && /*#__PURE__*/ new TextDecoder();
try {
td.decode(et, { stream: true });
} catch (e) {}
var dutf8 = function(d) {
for (var r = "", i = 0;;) {
var c = d[i++];
var eb = (c > 127) + (c > 223) + (c > 239);
if (i + eb > d.length) return [r, slc(d, i - 1)];
if (!eb) r += String.fromCharCode(c);
else if (eb == 3) c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
else if (eb & 1) r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);
else r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
}
};
/**
* Converts a string into a Uint8Array for use with compression/decompression methods
* @param str The string to encode
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless decoding a binary string.
* @returns The string encoded in UTF-8/Latin-1 binary
*/
function strToU8(str, latin1) {
if (latin1) {
var ar_1 = new u8(str.length);
for (var i = 0; i < str.length; ++i) ar_1[i] = str.charCodeAt(i);
return ar_1;
}
if (te) return te.encode(str);
var l = str.length;
var ar = new u8(str.length + (str.length >> 1));
var ai = 0;
var w = function(v) {
ar[ai++] = v;
};
for (var i = 0; i < l; ++i) {
if (ai + 5 > ar.length) {
var n = new u8(ai + 8 + (l - i << 1));
n.set(ar);
ar = n;
}
var c = str.charCodeAt(i);
if (c < 128 || latin1) w(c);
else if (c < 2048) w(192 | c >> 6), w(128 | c & 63);
else if (c > 55295 && c < 57344) c = 65536 + (c & 1047552) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
else w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
}
return slc(ar, 0, ai);
}
/**
* Converts a Uint8Array to a string
* @param dat The data to decode to string
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless encoding to binary string.
* @returns The original UTF-8/Latin-1 string
*/
function strFromU8(dat, latin1) {
if (latin1) {
var r = "";
for (var i = 0; i < dat.length; i += 16384) r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
return r;
} else if (td) return td.decode(dat);
else {
var _a = dutf8(dat), out = _a[0];
if (_a[1].length) throw "invalid utf-8 data";
return out;
}
}
var slzh = function(d, b) {
return b + 30 + b2(d, b + 26) + b2(d, b + 28);
};
var zh = function(d, b, z) {
var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
var _a = z && bs == 4294967295 ? z64e(d, es) : [
bs,
b4(d, b + 24),
b4(d, b + 42)
], sc = _a[0], su = _a[1], off = _a[2];
return [
b2(d, b + 10),
sc,
su,
fn,
es + b2(d, b + 30) + b2(d, b + 32),
off
];
};
var z64e = function(d, b) {
for (; b2(d, b) != 1; b += 4 + b2(d, b + 2));
return [
b8(d, b + 12),
b8(d, b + 4),
b8(d, b + 20)
];
};
var exfl = function(ex) {
var le = 0;
if (ex) for (var k in ex) {
var l = ex[k].length;
if (l > 65535) throw "extra field too long";
le += l + 4;
}
return le;
};
var wzh = function(d, b, f, fn, u, c, ce, co) {
var fl = fn.length, ex = f.extra, col = co && co.length;
var exl = exfl(ex);
wbytes(d, b, ce != null ? 33639248 : 67324752), b += 4;
if (ce != null) d[b++] = 20, d[b++] = f.os;
d[b] = 20, b += 2;
d[b++] = f.flag << 1 | (c == null && 8), d[b++] = u && 8;
d[b++] = f.compression & 255, d[b++] = f.compression >> 8;
var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;
if (y < 0 || y > 119) throw "date not in range 1980-2099";
wbytes(d, b, y << 25 | dt.getMonth() + 1 << 21 | dt.getDate() << 16 | dt.getHours() << 11 | dt.getMinutes() << 5 | dt.getSeconds() >>> 1), b += 4;
if (c != null) {
wbytes(d, b, f.crc);
wbytes(d, b + 4, c);
wbytes(d, b + 8, f.size);
}
wbytes(d, b + 12, fl);
wbytes(d, b + 14, exl), b += 16;
if (ce != null) {
wbytes(d, b, col);
wbytes(d, b + 6, f.attrs);
wbytes(d, b + 10, ce), b += 14;
}
d.set(fn, b);
b += fl;
if (exl) for (var k in ex) {
var exf = ex[k], l = exf.length;
wbytes(d, b, +k);
wbytes(d, b + 2, l);
d.set(exf, b + 4), b += 4 + l;
}
if (col) d.set(co, b), b += col;
return b;
};
var wzf = function(o, b, c, d, e) {
wbytes(o, b, 101010256);
wbytes(o, b + 8, c);
wbytes(o, b + 10, c);
wbytes(o, b + 12, d);
wbytes(o, b + 16, e);
};
/**
* Synchronously creates a ZIP file. Prefer using `zip` for better performance
* with more than one file.
* @param data The directory structure for the ZIP archive
* @param opts The main options, merged with per-file options
* @returns The generated ZIP archive
*/
function zipSync(data, opts) {
if (!opts) opts = {};
var r = {};
var files = [];
fltn(data, "", r, opts);
var o = 0;
var tot = 0;
for (var fn in r) {
var _a = r[fn], file = _a[0], p = _a[1];
var compression = p.level == 0 ? 0 : 8;
var f = strToU8(fn), s = f.length;
var com = p.comment, m = com && strToU8(com), ms = m && m.length;
var exl = exfl(p.extra);
if (s > 65535) throw "filename too long";
var d = compression ? deflateSync(file, p) : file, l = d.length;
var c = crc();
c.p(file);
files.push(mrg(p, {
size: file.length,
crc: c.d(),
c: d,
f,
m,
u: s != fn.length || m && com.length != ms,
o,
compression
}));
o += 30 + s + exl + l;
tot += 76 + 2 * (s + exl) + (ms || 0) + l;
}
var out = new u8(tot + 22), oe = o, cdl = tot - o;
for (var i = 0; i < files.length; ++i) {
var f = files[i];
wzh(out, f.o, f, f.f, f.u, f.c.length);
var badd = 30 + f.f.length + exfl(f.extra);
out.set(f.c, f.o + badd);
wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);
}
wzf(out, o, files.length, cdl, oe);
return out;
}
/**
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
* performance with more than one file.
* @param data The raw compressed ZIP file
* @returns The decompressed files
*/
function unzipSync(data) {
var files = {};
var e = data.length - 22;
for (; b4(data, e) != 101010256; --e) if (!e || data.length - e > 65558) throw "invalid zip file";
var c = b2(data, e + 8);
if (!c) return {};
var o = b4(data, e + 16);
var z = o == 4294967295;
if (z) {
e = b4(data, e - 12);
if (b4(data, e) != 101075792) throw "invalid zip file";
c = b4(data, e + 32);
o = b4(data, e + 48);
}
for (var i = 0; i < c; ++i) {
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);
o = no;
if (!c_2) files[fn] = slc(data, b, b + sc);
else if (c_2 == 8) files[fn] = inflateSync(data.subarray(b, b + sc), new u8(su));
else throw "unknown compression type " + c_2;
}
return files;
}
//#endregion
//#region node_modules/three-stdlib/exporters/USDZExporter.js
var __defProp$53 = Object.defineProperty;
var __defNormalProp$53 = (obj, key, value) => key in obj ? __defProp$53(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$53 = (obj, key, value) => {
__defNormalProp$53(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var USDZExporter = class {
constructor() {
__publicField$53(this, "PRECISION", 7);
__publicField$53(this, "materials");
__publicField$53(this, "textures");
__publicField$53(this, "files");
this.materials = {};
this.textures = {};
this.files = {};
}
async parse(scene) {
const modelFileName = "model.usda";
this.files[modelFileName] = null;
let output = this.buildHeader();
scene.traverseVisible((object) => {
if (object instanceof Mesh && object.isMesh && object.material.isMeshStandardMaterial) {
const geometry = object.geometry;
const material = object.material;
const geometryFileName = "geometries/Geometry_" + geometry.id + ".usd";
if (!(geometryFileName in this.files)) {
const meshObject = this.buildMeshObject(geometry);
this.files[geometryFileName] = this.buildUSDFileAsString(meshObject);
}
if (!(material.uuid in this.materials)) this.materials[material.uuid] = material;
output += this.buildXform(object, geometry, material);
}
});
output += this.buildMaterials(this.materials);
this.files[modelFileName] = strToU8(output);
output = null;
for (const id in this.textures) {
const texture = this.textures[id];
const color = id.split("_")[1];
const isRGBA = texture.format === 1023;
const canvas = this.imageToCanvas(texture.image, color);
const blob = await new Promise((resolve) => canvas == null ? void 0 : canvas.toBlob(resolve, isRGBA ? "image/png" : "image/jpeg", 1));
if (blob) this.files[`textures/Texture_${id}.${isRGBA ? "png" : "jpg"}`] = new Uint8Array(await blob.arrayBuffer());
}
let offset = 0;
for (const filename in this.files) {
const file = this.files[filename];
const headerSize = 34 + filename.length;
offset += headerSize;
const offsetMod64 = offset & 63;
if (offsetMod64 !== 4 && file !== null && file instanceof Uint8Array) {
const padLength = 64 - offsetMod64;
const padding = new Uint8Array(padLength);
this.files[filename] = [file, { extra: { 12345: padding } }];
}
if (file && typeof file.length === "number") offset = file.length;
}
return zipSync(this.files, { level: 0 });
}
imageToCanvas(image, color) {
if (typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== "undefined" && image instanceof HTMLCanvasElement || typeof OffscreenCanvas !== "undefined" && image instanceof OffscreenCanvas || typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
const scale = 1024 / Math.max(image.width, image.height);
const canvas = document.createElement("canvas");
canvas.width = image.width * Math.min(1, scale);
canvas.height = image.height * Math.min(1, scale);
const context = canvas.getContext("2d");
context?.drawImage(image, 0, 0, canvas.width, canvas.height);
if (color !== void 0) {
const hex = parseInt(color, 16);
const r = (hex >> 16 & 255) / 255;
const g = (hex >> 8 & 255) / 255;
const b = (hex & 255) / 255;
const imagedata = context == null ? void 0 : context.getImageData(0, 0, canvas.width, canvas.height);
if (imagedata) {
const data = imagedata == null ? void 0 : imagedata.data;
for (let i = 0; i < data.length; i += 4) {
data[i + 0] = data[i + 0] * r;
data[i + 1] = data[i + 1] * g;
data[i + 2] = data[i + 2] * b;
}
context?.putImageData(imagedata, 0, 0);
}
}
return canvas;
}
}
buildHeader() {
return `#usda 1.0
(
customLayerData = {
string creator = "Three.js USDZExporter"
}
metersPerUnit = 1
upAxis = "Y"
)
`;
}
buildUSDFileAsString(dataToInsert) {
let output = this.buildHeader();
output += dataToInsert;
return strToU8(output);
}
buildXform(object, geometry, material) {
const name = "Object_" + object.id;
const transform = this.buildMatrix(object.matrixWorld);
if (object.matrixWorld.determinant() < 0) console.warn("THREE.USDZExporter: USDZ does not support negative scales", object);
return `def Xform "${name}" (
prepend references = @./geometries/Geometry_${geometry.id}.usd@
)
{
matrix4d xformOp:transform = ${transform}
uniform token[] xformOpOrder = ["xformOp:transform"]
rel material:binding =
}
`;
}
buildMatrix(matrix) {
const array = matrix.elements;
return `( ${this.buildMatrixRow(array, 0)}, ${this.buildMatrixRow(array, 4)}, ${this.buildMatrixRow(array, 8)}, ${this.buildMatrixRow(array, 12)} )`;
}
buildMatrixRow(array, offset) {
return `(${array[offset + 0]}, ${array[offset + 1]}, ${array[offset + 2]}, ${array[offset + 3]})`;
}
buildMeshObject(geometry) {
return `
def "Geometry"
{
${this.buildMesh(geometry)}
}
`;
}
buildMesh(geometry) {
const name = "Geometry";
const attributes = geometry.attributes;
const count = attributes.position.count;
return `
def Mesh "${name}"
{
int[] faceVertexCounts = [${this.buildMeshVertexCount(geometry)}]
int[] faceVertexIndices = [${this.buildMeshVertexIndices(geometry)}]
normal3f[] normals = [${this.buildVector3Array(attributes.normal, count)}] (
interpolation = "vertex"
)
point3f[] points = [${this.buildVector3Array(attributes.position, count)}]
float2[] primvars:st = [${this.buildVector2Array(attributes.uv, count)}] (
interpolation = "vertex"
)
uniform token subdivisionScheme = "none"
}
`;
}
buildMeshVertexCount(geometry) {
const count = geometry.index !== null ? geometry.index.array.length : geometry.attributes.position.count;
return Array(count / 3).fill(3).join(", ");
}
buildMeshVertexIndices(geometry) {
if (geometry.index !== null) return geometry.index.array.join(", ");
const array = [];
const length = geometry.attributes.position.count;
for (let i = 0; i < length; i++) array.push(i);
return array.join(", ");
}
buildVector3Array(attribute, count) {
if (attribute === void 0) {
console.warn("USDZExporter: Normals missing.");
return Array(count).fill("(0, 0, 0)").join(", ");
}
const array = [];
const data = attribute.array;
for (let i = 0; i < data.length; i += 3) array.push(`(${data[i + 0].toPrecision(this.PRECISION)}, ${data[i + 1].toPrecision(this.PRECISION)}, ${data[i + 2].toPrecision(this.PRECISION)})`);
return array.join(", ");
}
buildVector2Array(attribute, count) {
if (attribute === void 0) {
console.warn("USDZExporter: UVs missing.");
return Array(count).fill("(0, 0)").join(", ");
}
const array = [];
const data = attribute.array;
for (let i = 0; i < data.length; i += 2) array.push(`(${data[i + 0].toPrecision(this.PRECISION)}, ${1 - data[i + 1].toPrecision(this.PRECISION)})`);
return array.join(", ");
}
buildMaterials(materials) {
const array = [];
for (const uuid in materials) {
const material = materials[uuid];
array.push(this.buildMaterial(material));
}
return `def "Materials"
{
${array.join("")}
}
`;
}
buildMaterial(material) {
const pad = " ";
const inputs = [];
const samplers = [];
if (material.map !== null) {
inputs.push(`${pad}color3f inputs:diffuseColor.connect = `);
if (material.transparent || material.alphaTest > 0) inputs.push(`${pad}float inputs:opacity.connect = `);
if (material.alphaTest > .01) inputs.push(`${pad}float inputs:opacityThreshold = ${material.alphaTest}`);
else if (material.transparent || material.alphaTest > 0) inputs.push(`${pad}float inputs:opacityThreshold = 0.01`);
samplers.push(this.buildTexture(material, material.map, "diffuse", material.color));
} else inputs.push(`${pad}color3f inputs:diffuseColor = ${this.buildColor(material.color)}`);
if (material.emissiveMap !== null) {
inputs.push(`${pad}color3f inputs:emissiveColor.connect = `);
samplers.push(this.buildTexture(material, material.emissiveMap, "emissive"));
} else if (material.emissive.getHex() > 0) inputs.push(`${pad}color3f inputs:emissiveColor = ${this.buildColor(material.emissive)}`);
if (material.normalMap !== null) {
inputs.push(`${pad}normal3f inputs:normal.connect = `);
samplers.push(this.buildTexture(material, material.normalMap, "normal"));
}
if (material.aoMap !== null) {
inputs.push(`${pad}float inputs:occlusion.connect = `);
samplers.push(this.buildTexture(material, material.aoMap, "occlusion"));
}
if (material.roughnessMap !== null && material.roughness === 1) {
inputs.push(`${pad}float inputs:roughness.connect = `);
samplers.push(this.buildTexture(material, material.roughnessMap, "roughness"));
} else inputs.push(`${pad}float inputs:roughness = ${material.roughness}`);
if (material.metalnessMap !== null && material.metalness === 1) {
inputs.push(`${pad}float inputs:metallic.connect = `);
samplers.push(this.buildTexture(material, material.metalnessMap, "metallic"));
} else inputs.push(`${pad}float inputs:metallic = ${material.metalness}`);
inputs.push(`${pad}float inputs:opacity = ${material.opacity}`);
if (material instanceof MeshPhysicalMaterial) {
inputs.push(`${pad}float inputs:clearcoat = ${material.clearcoat}`);
inputs.push(`${pad}float inputs:clearcoatRoughness = ${material.clearcoatRoughness}`);
inputs.push(`${pad}float inputs:ior = ${material.ior}`);
}
return `
def Material "Material_${material.id}"
{
def Shader "PreviewSurface"
{
uniform token info:id = "UsdPreviewSurface"
${inputs.join("\n")}
int inputs:useSpecularWorkflow = 0
token outputs:surface
}
token outputs:surface.connect =
token inputs:frame:stPrimvarName = "st"
def Shader "uvReader_st"
{
uniform token info:id = "UsdPrimvarReader_float2"
token inputs:varname.connect =
float2 inputs:fallback = (0.0, 0.0)
float2 outputs:result
}
${samplers.join("\n")}
}
`;
}
buildTexture(material, texture, mapType, color) {
const id = texture.id + (color ? "_" + color.getHexString() : "");
const isRGBA = texture.format === 1023;
this.textures[id] = texture;
return `
def Shader "Transform2d_${mapType}" (
sdrMetadata = {
string role = "math"
}
)
{
uniform token info:id = "UsdTransform2d"
float2 inputs:in.connect =
float2 inputs:scale = ${this.buildVector2(texture.repeat)}
float2 inputs:translation = ${this.buildVector2(texture.offset)}
float2 outputs:result
}
def Shader "Texture_${texture.id}_${mapType}"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textures/Texture_${id}.${isRGBA ? "png" : "jpg"}@
float2 inputs:st.connect =
token inputs:wrapS = "repeat"
token inputs:wrapT = "repeat"
float outputs:r
float outputs:g
float outputs:b
float3 outputs:rgb
${material.transparent || material.alphaTest > 0 ? "float outputs:a" : ""}
}`;
}
buildColor(color) {
return `(${color.r}, ${color.g}, ${color.b})`;
}
buildVector2(vector) {
return `(${vector.x}, ${vector.y})`;
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/PLYExporter.js
var PLYExporter = class {
parse(object, onDone, options) {
if (onDone && typeof onDone === "object") {
console.warn("THREE.PLYExporter: The options parameter is now the third argument to the \"parse\" function. See the documentation for the new API.");
options = onDone;
onDone = void 0;
}
options = Object.assign({
binary: false,
excludeAttributes: [],
littleEndian: false
}, options);
const excludeAttributes = options.excludeAttributes;
let includeNormals = false;
let includeColors = false;
let includeUVs = false;
let vertexCount = 0;
let faceCount = 0;
object.traverse(function(child) {
if (child instanceof Mesh && child.isMesh) {
const geometry = child.geometry;
if (!geometry.isBufferGeometry) throw new Error("THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.");
const vertices = geometry.getAttribute("position");
const normals = geometry.getAttribute("normal");
const uvs = geometry.getAttribute("uv");
const colors = geometry.getAttribute("color");
const indices = geometry.getIndex();
if (vertices === void 0) return;
vertexCount += vertices.count;
faceCount += indices ? indices.count / 3 : vertices.count / 3;
if (normals !== void 0) includeNormals = true;
if (uvs !== void 0) includeUVs = true;
if (colors !== void 0) includeColors = true;
}
});
const includeIndices = (excludeAttributes == null ? void 0 : excludeAttributes.indexOf("index")) === -1;
includeNormals = includeNormals && (excludeAttributes == null ? void 0 : excludeAttributes.indexOf("normal")) === -1;
includeColors = includeColors && (excludeAttributes == null ? void 0 : excludeAttributes.indexOf("color")) === -1;
includeUVs = includeUVs && (excludeAttributes == null ? void 0 : excludeAttributes.indexOf("uv")) === -1;
if (includeIndices && faceCount !== Math.floor(faceCount)) {
console.error("PLYExporter: Failed to generate a valid PLY file with triangle indices because the number of indices is not divisible by 3.");
return null;
}
const indexByteCount = 4;
let header = `ply
format ${options.binary ? options.littleEndian ? "binary_little_endian" : "binary_big_endian" : "ascii"} 1.0
element vertex ${vertexCount}
property float x
property float y
property float z
`;
if (includeNormals) header += "property float nx\nproperty float ny\nproperty float nz\n";
if (includeUVs) header += "property float s\nproperty float t\n";
if (includeColors) header += "property uchar red\nproperty uchar green\nproperty uchar blue\n";
if (includeIndices) header += `${`element face ${faceCount}
`}property list uchar int vertex_index
`;
header += "end_header\n";
const vertex = new Vector3();
const normalMatrixWorld = new Matrix3();
let result = null;
if (options.binary) {
const headerBin = new TextEncoder().encode(header);
const vertexListLength = vertexCount * (12 + (includeNormals ? 12 : 0) + (includeColors ? 3 : 0) + (includeUVs ? 8 : 0));
const faceListLength = includeIndices ? faceCount * 13 : 0;
const output = new DataView(new ArrayBuffer(headerBin.length + vertexListLength + faceListLength));
new Uint8Array(output.buffer).set(headerBin, 0);
let vOffset = headerBin.length;
let fOffset = headerBin.length + vertexListLength;
let writtenVertices = 0;
this.traverseMeshes(object, function(mesh, geometry) {
const vertices = geometry.getAttribute("position");
const normals = geometry.getAttribute("normal");
const uvs = geometry.getAttribute("uv");
const colors = geometry.getAttribute("color");
const indices = geometry.getIndex();
normalMatrixWorld.getNormalMatrix(mesh.matrixWorld);
for (let i = 0, l = vertices.count; i < l; i++) {
vertex.x = vertices.getX(i);
vertex.y = vertices.getY(i);
vertex.z = vertices.getZ(i);
vertex.applyMatrix4(mesh.matrixWorld);
output.setFloat32(vOffset, vertex.x, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, vertex.y, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, vertex.z, options.littleEndian);
vOffset += 4;
if (includeNormals) if (normals != null) {
vertex.x = normals.getX(i);
vertex.y = normals.getY(i);
vertex.z = normals.getZ(i);
vertex.applyMatrix3(normalMatrixWorld).normalize();
output.setFloat32(vOffset, vertex.x, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, vertex.y, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, vertex.z, options.littleEndian);
vOffset += 4;
} else {
output.setFloat32(vOffset, 0, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, 0, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, 0, options.littleEndian);
vOffset += 4;
}
if (includeUVs) {
if (uvs != null) {
output.setFloat32(vOffset, uvs.getX(i), options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, uvs.getY(i), options.littleEndian);
vOffset += 4;
} else if (!includeUVs) {
output.setFloat32(vOffset, 0, options.littleEndian);
vOffset += 4;
output.setFloat32(vOffset, 0, options.littleEndian);
vOffset += 4;
}
}
if (includeColors) if (colors != null) {
output.setUint8(vOffset, Math.floor(colors.getX(i) * 255));
vOffset += 1;
output.setUint8(vOffset, Math.floor(colors.getY(i) * 255));
vOffset += 1;
output.setUint8(vOffset, Math.floor(colors.getZ(i) * 255));
vOffset += 1;
} else {
output.setUint8(vOffset, 255);
vOffset += 1;
output.setUint8(vOffset, 255);
vOffset += 1;
output.setUint8(vOffset, 255);
vOffset += 1;
}
}
if (includeIndices) if (indices !== null) for (let i = 0, l = indices.count; i < l; i += 3) {
output.setUint8(fOffset, 3);
fOffset += 1;
output.setUint32(fOffset, indices.getX(i + 0) + writtenVertices, options.littleEndian);
fOffset += indexByteCount;
output.setUint32(fOffset, indices.getX(i + 1) + writtenVertices, options.littleEndian);
fOffset += indexByteCount;
output.setUint32(fOffset, indices.getX(i + 2) + writtenVertices, options.littleEndian);
fOffset += indexByteCount;
}
else for (let i = 0, l = vertices.count; i < l; i += 3) {
output.setUint8(fOffset, 3);
fOffset += 1;
output.setUint32(fOffset, writtenVertices + i, options.littleEndian);
fOffset += indexByteCount;
output.setUint32(fOffset, writtenVertices + i + 1, options.littleEndian);
fOffset += indexByteCount;
output.setUint32(fOffset, writtenVertices + i + 2, options.littleEndian);
fOffset += indexByteCount;
}
writtenVertices += vertices.count;
});
result = output.buffer;
} else {
let writtenVertices = 0;
let vertexList = "";
let faceList = "";
this.traverseMeshes(object, function(mesh, geometry) {
const vertices = geometry.getAttribute("position");
const normals = geometry.getAttribute("normal");
const uvs = geometry.getAttribute("uv");
const colors = geometry.getAttribute("color");
const indices = geometry.getIndex();
normalMatrixWorld.getNormalMatrix(mesh.matrixWorld);
for (let i = 0, l = vertices.count; i < l; i++) {
vertex.x = vertices.getX(i);
vertex.y = vertices.getY(i);
vertex.z = vertices.getZ(i);
vertex.applyMatrix4(mesh.matrixWorld);
let line = vertex.x + " " + vertex.y + " " + vertex.z;
if (includeNormals) if (normals != null) {
vertex.x = normals.getX(i);
vertex.y = normals.getY(i);
vertex.z = normals.getZ(i);
vertex.applyMatrix3(normalMatrixWorld).normalize();
line += " " + vertex.x + " " + vertex.y + " " + vertex.z;
} else line += " 0 0 0";
if (includeUVs) {
if (uvs != null) line += " " + uvs.getX(i) + " " + uvs.getY(i);
else if (includeUVs) line += " 0 0";
}
if (includeColors) if (colors != null) line += " " + Math.floor(colors.getX(i) * 255) + " " + Math.floor(colors.getY(i) * 255) + " " + Math.floor(colors.getZ(i) * 255);
else line += " 255 255 255";
vertexList += line + "\n";
}
if (includeIndices) {
if (indices !== null) for (let i = 0, l = indices.count; i < l; i += 3) {
faceList += `3 ${indices.getX(i + 0) + writtenVertices}`;
faceList += ` ${indices.getX(i + 1) + writtenVertices}`;
faceList += ` ${indices.getX(i + 2) + writtenVertices}
`;
}
else for (let i = 0, l = vertices.count; i < l; i += 3) faceList += `3 ${writtenVertices + i} ${writtenVertices + i + 1} ${writtenVertices + i + 2}
`;
faceCount += indices ? indices.count / 3 : vertices.count / 3;
}
writtenVertices += vertices.count;
});
result = `${header}${vertexList}${includeIndices ? `${faceList}
` : "\n"}`;
}
if (typeof onDone === "function") requestAnimationFrame(() => onDone && onDone(typeof result === "string" ? result : ""));
return result;
}
traverseMeshes(object, cb) {
object.traverse(function(child) {
if (child instanceof Mesh && child.isMesh) {
const mesh = child;
const geometry = mesh.geometry;
if (!geometry.isBufferGeometry) throw new Error("THREE.PLYExporter: Geometry is not of type THREE.BufferGeometry.");
if (geometry.hasAttribute("position")) cb(mesh, geometry);
}
});
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/DRACOExporter.js
var __defProp$52 = Object.defineProperty;
var __defNormalProp$52 = (obj, key, value) => key in obj ? __defProp$52(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$52 = (obj, key, value) => {
__defNormalProp$52(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var DRACOExporter = /* @__PURE__ */ (() => {
const _DRACOExporter = class {
parse(object, options = {
decodeSpeed: 5,
encodeSpeed: 5,
encoderMethod: _DRACOExporter.MESH_EDGEBREAKER_ENCODING,
quantization: [
16,
8,
8,
8,
8
],
exportUvs: true,
exportNormals: true,
exportColor: false
}) {
if (object instanceof BufferGeometry && object.isBufferGeometry) throw new Error("DRACOExporter: The first parameter of parse() is now an instance of Mesh or Points.");
if (DracoEncoderModule === void 0) throw new Error("THREE.DRACOExporter: required the draco_encoder to work.");
const geometry = object.geometry;
const dracoEncoder = DracoEncoderModule();
const encoder = new dracoEncoder.Encoder();
let builder;
let dracoObject;
if (!geometry.isBufferGeometry) throw new Error("THREE.DRACOExporter.parse(geometry, options): geometry is not a THREE.BufferGeometry instance.");
if (object instanceof Mesh && object.isMesh) {
builder = new dracoEncoder.MeshBuilder();
dracoObject = new dracoEncoder.Mesh();
const vertices = geometry.getAttribute("position");
builder.AddFloatAttributeToMesh(dracoObject, dracoEncoder.POSITION, vertices.count, vertices.itemSize, vertices.array);
const faces = geometry.getIndex();
if (faces !== null) builder.AddFacesToMesh(dracoObject, faces.count / 3, faces.array);
else {
const faces2 = new (vertices.count > 65535 ? Uint32Array : Uint16Array)(vertices.count);
for (let i = 0; i < faces2.length; i++) faces2[i] = i;
builder.AddFacesToMesh(dracoObject, vertices.count, faces2);
}
if (options.exportNormals) {
const normals = geometry.getAttribute("normal");
if (normals !== void 0) builder.AddFloatAttributeToMesh(dracoObject, dracoEncoder.NORMAL, normals.count, normals.itemSize, normals.array);
}
if (options.exportUvs) {
const uvs = geometry.getAttribute("uv");
if (uvs !== void 0) builder.AddFloatAttributeToMesh(dracoObject, dracoEncoder.TEX_COORD, uvs.count, uvs.itemSize, uvs.array);
}
if (options.exportColor) {
const colors = geometry.getAttribute("color");
if (colors !== void 0) builder.AddFloatAttributeToMesh(dracoObject, dracoEncoder.COLOR, colors.count, colors.itemSize, colors.array);
}
} else if (object instanceof Points && object.isPoints) {
builder = new dracoEncoder.PointCloudBuilder();
dracoObject = new dracoEncoder.PointCloud();
const vertices = geometry.getAttribute("position");
builder.AddFloatAttribute(dracoObject, dracoEncoder.POSITION, vertices.count, vertices.itemSize, vertices.array);
if (options.exportColor) {
const colors = geometry.getAttribute("color");
if (colors !== void 0) builder.AddFloatAttribute(dracoObject, dracoEncoder.COLOR, colors.count, colors.itemSize, colors.array);
}
} else throw new Error("DRACOExporter: Unsupported object type.");
const encodedData = new dracoEncoder.DracoInt8Array();
const encodeSpeed = options.encodeSpeed !== void 0 ? options.encodeSpeed : 5;
const decodeSpeed = options.decodeSpeed !== void 0 ? options.decodeSpeed : 5;
encoder.SetSpeedOptions(encodeSpeed, decodeSpeed);
if (options.encoderMethod !== void 0) encoder.SetEncodingMethod(options.encoderMethod);
if (options.quantization !== void 0) {
for (let i = 0; i < 5; i++) if (options.quantization[i] !== void 0) encoder.SetAttributeQuantization(i, options.quantization[i]);
}
let length;
if (object instanceof Mesh && object.isMesh) length = encoder.EncodeMeshToDracoBuffer(dracoObject, encodedData);
else length = encoder.EncodePointCloudToDracoBuffer(dracoObject, true, encodedData);
dracoEncoder.destroy(dracoObject);
if (length === 0) throw new Error("THREE.DRACOExporter: Draco encoding failed.");
const outputData = new Int8Array(new ArrayBuffer(length));
for (let i = 0; i < length; i++) outputData[i] = encodedData.GetValue(i);
dracoEncoder.destroy(encodedData);
dracoEncoder.destroy(encoder);
dracoEncoder.destroy(builder);
return outputData;
}
};
let DRACOExporter2 = _DRACOExporter;
__publicField$52(DRACOExporter2, "MESH_EDGEBREAKER_ENCODING", 1);
__publicField$52(DRACOExporter2, "MESH_SEQUENTIAL_ENCODING", 0);
__publicField$52(DRACOExporter2, "POINT_CLOUD", 0);
__publicField$52(DRACOExporter2, "TRIANGULAR_MESH", 1);
__publicField$52(DRACOExporter2, "INVALID", -1);
__publicField$52(DRACOExporter2, "POSITION", 0);
__publicField$52(DRACOExporter2, "NORMAL", 1);
__publicField$52(DRACOExporter2, "COLOR", 2);
__publicField$52(DRACOExporter2, "TEX_COORD", 3);
__publicField$52(DRACOExporter2, "GENERIC", 4);
return DRACOExporter2;
})();
//#endregion
//#region node_modules/three-stdlib/exporters/ColladaExporter.js
var __defProp$51 = Object.defineProperty;
var __defNormalProp$51 = (obj, key, value) => key in obj ? __defProp$51(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$51 = (obj, key, value) => {
__defNormalProp$51(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var ColladaExporter = class {
constructor() {
__publicField$51(this, "options");
__publicField$51(this, "geometryInfo");
__publicField$51(this, "materialMap");
__publicField$51(this, "imageMap");
__publicField$51(this, "textures");
__publicField$51(this, "libraryImages");
__publicField$51(this, "libraryGeometries");
__publicField$51(this, "libraryEffects");
__publicField$51(this, "libraryMaterials");
__publicField$51(this, "canvas");
__publicField$51(this, "ctx");
__publicField$51(this, "transMat");
__publicField$51(this, "getFuncs", [
"getX",
"getY",
"getZ",
"getW"
]);
this.options = {
version: "1.4.1",
author: null,
textureDirectory: "",
upAxis: "Y_UP",
unitName: null,
unitMeter: null
};
this.geometryInfo = /* @__PURE__ */ new WeakMap();
this.materialMap = /* @__PURE__ */ new WeakMap();
this.imageMap = /* @__PURE__ */ new WeakMap();
this.textures = [];
this.libraryImages = [];
this.libraryGeometries = [];
this.libraryEffects = [];
this.libraryMaterials = [];
this.canvas = null;
this.ctx = null;
this.transMat = null;
}
parse(object, onDone, options = {}) {
this.options = {
...this.options,
...options
};
if (this.options.upAxis.match(/^[XYZ]_UP$/) === null) {
console.error("ColladaExporter: Invalid upAxis: valid values are X_UP, Y_UP or Z_UP.");
return null;
}
if (this.options.unitName !== null && this.options.unitMeter === null) {
console.error("ColladaExporter: unitMeter needs to be specified if unitName is specified.");
return null;
}
if (this.options.unitMeter !== null && this.options.unitName === null) {
console.error("ColladaExporter: unitName needs to be specified if unitMeter is specified.");
return null;
}
if (this.options.textureDirectory !== "") this.options.textureDirectory = `${this.options.textureDirectory}/`.replace(/\\/g, "/").replace(/\/+/g, "/");
if (this.options.version !== "1.4.1" && this.options.version !== "1.5.0") {
console.warn(`ColladaExporter : Version ${this.options.version} not supported for export. Only 1.4.1 and 1.5.0.`);
return null;
}
const libraryVisualScenes = this.processObject(object);
let dae = `${``}three.js Collada Exporter${this.options.author !== null ? `${this.options.author}` : ""}${`${(/* @__PURE__ */ new Date()).toISOString()}`}${`${(/* @__PURE__ */ new Date()).toISOString()}`}Y_UP`;
dae += `${this.libraryImages.join("")}`;
dae += `${this.libraryEffects.join("")}`;
dae += `${this.libraryMaterials.join("")}`;
dae += `${this.libraryGeometries.join("")}`;
dae += `${libraryVisualScenes}`;
dae += "";
dae += "";
const res = {
data: this.format(dae),
textures: this.textures
};
if (typeof onDone === "function") requestAnimationFrame(() => onDone(res));
return res;
}
format(urdf) {
var _a, _b;
const IS_END_TAG = /^<\//;
const IS_SELF_CLOSING = /(\?>$)|(\/>$)/;
const HAS_TEXT = /<[^>]+>[^<]*<\/[^<]+>/;
const pad = (ch, num) => num > 0 ? ch + pad(ch, num - 1) : "";
let tagnum = 0;
return (_b = (_a = urdf.match(/(<[^>]+>[^<]+<\/[^<]+>)|(<[^>]+>)/g)) == null ? void 0 : _a.map((tag) => {
if (!HAS_TEXT.test(tag) && !IS_SELF_CLOSING.test(tag) && IS_END_TAG.test(tag)) tagnum--;
const res = `${pad(" ", tagnum)}${tag}`;
if (!HAS_TEXT.test(tag) && !IS_SELF_CLOSING.test(tag) && !IS_END_TAG.test(tag)) tagnum++;
return res;
}).join("\n")) != null ? _b : "";
}
base64ToBuffer(str) {
const b = atob(str);
const buf = new Uint8Array(b.length);
for (let i = 0, l = buf.length; i < l; i++) buf[i] = b.charCodeAt(i);
return buf;
}
imageToData(image, ext) {
var _a;
this.canvas = this.canvas || document.createElement("canvas");
this.ctx = this.ctx || this.canvas.getContext("2d");
this.canvas.width = image.width instanceof SVGAnimatedLength ? 0 : image.width;
this.canvas.height = image.height instanceof SVGAnimatedLength ? 0 : image.height;
(_a = this.ctx) == null || _a.drawImage(image, 0, 0);
const base64data = this.canvas.toDataURL(`image/${ext}`, 1).replace(/^data:image\/(png|jpg);base64,/, "");
return this.base64ToBuffer(base64data);
}
attrBufferToArray(attr) {
if (attr instanceof InterleavedBufferAttribute && attr.isInterleavedBufferAttribute) {
const TypedArrayConstructor = attr.array.constructor;
const arr = new TypedArrayConstructor(attr.count * attr.itemSize);
const size = attr.itemSize;
for (let i = 0, l = attr.count; i < l; i++) for (let j = 0; j < size; j++) arr[i * size + j] = attr[this.getFuncs[j]](i);
return arr;
} else return attr.array;
}
subArray(arr, st, ct) {
if (Array.isArray(arr)) return arr.slice(st, st + ct);
else {
const TypedArrayConstructor = arr.constructor;
return new TypedArrayConstructor(arr.buffer, st * arr.BYTES_PER_ELEMENT, ct);
}
}
getAttribute(attr, name, params, type) {
const array = this.attrBufferToArray(attr);
return Array.isArray(array) ? `${`` + array.join(" ")}${``}${params.map((n) => ``).join("")}` : "";
}
getTransform(o) {
o.updateMatrix();
this.transMat = this.transMat || new Matrix4();
this.transMat.copy(o.matrix);
this.transMat.transpose();
return `${this.transMat.toArray().join(" ")}`;
}
processGeometry(g) {
let info = this.geometryInfo.get(g);
if (!info) {
const bufferGeometry = g;
if (!bufferGeometry.isBufferGeometry) throw new Error("THREE.ColladaExporter: Geometry is not of type THREE.BufferGeometry.");
const meshid = `Mesh${this.libraryGeometries.length + 1}`;
const indexCount = bufferGeometry.index ? bufferGeometry.index.count * bufferGeometry.index.itemSize : bufferGeometry.attributes.position.count;
const groups = bufferGeometry.groups != null && bufferGeometry.groups.length !== 0 ? bufferGeometry.groups : [{
start: 0,
count: indexCount,
materialIndex: 0
}];
let gnode = ``;
const posName = `${meshid}-position`;
const vertName = `${meshid}-vertices`;
gnode += this.getAttribute(bufferGeometry.attributes.position, posName, [
"X",
"Y",
"Z"
], "float");
gnode += ``;
let triangleInputs = ``;
if ("normal" in bufferGeometry.attributes) {
const normName = `${meshid}-normal`;
gnode += this.getAttribute(bufferGeometry.attributes.normal, normName, [
"X",
"Y",
"Z"
], "float");
triangleInputs += ``;
}
if ("uv" in bufferGeometry.attributes) {
const uvName = `${meshid}-texcoord`;
gnode += this.getAttribute(bufferGeometry.attributes.uv, uvName, ["S", "T"], "float");
triangleInputs += ``;
}
if (UV1 in bufferGeometry.attributes) {
const uvName = `${meshid}-texcoord2`;
gnode += this.getAttribute(bufferGeometry.attributes[UV1], uvName, ["S", "T"], "float");
triangleInputs += ``;
}
if ("color" in bufferGeometry.attributes) {
const colName = `${meshid}-color`;
gnode += this.getAttribute(bufferGeometry.attributes.color, colName, [
"X",
"Y",
"Z"
], "uint8");
triangleInputs += ``;
}
let indexArray = null;
if (bufferGeometry.index) indexArray = this.attrBufferToArray(bufferGeometry.index);
else {
indexArray = new Array(indexCount);
for (let i = 0, l = indexArray.length; i < l && Array.isArray(indexArray); i++) indexArray[i] = i;
}
for (let i = 0, l = groups.length; i < l; i++) {
const group = groups[i];
const subarr = this.subArray(indexArray, group.start, group.count);
const polycount = subarr.length / 3;
gnode += ``;
gnode += triangleInputs;
gnode += `${subarr.join(" ")}
`;
gnode += "";
}
gnode += "";
this.libraryGeometries.push(gnode);
info = {
meshid,
bufferGeometry
};
this.geometryInfo.set(g, info);
}
return info;
}
processTexture(tex) {
let texid = this.imageMap.get(tex);
if (texid == null) {
texid = `image-${this.libraryImages.length + 1}`;
const ext = "png";
const name = tex.name || texid;
let imageNode = ``;
if (this.options.version === "1.5.0") imageNode += `[${this.options.textureDirectory}${name}.${ext}]`;
else imageNode += `${this.options.textureDirectory}${name}.${ext}`;
imageNode += "";
this.libraryImages.push(imageNode);
this.imageMap.set(tex, texid);
this.textures.push({
directory: this.options.textureDirectory,
name,
ext,
data: this.imageToData(tex.image, ext),
original: tex
});
}
return texid;
}
processMaterial(m) {
let matid = this.materialMap.get(m);
if (matid == null) {
matid = `Mat${this.libraryEffects.length + 1}`;
let type = "phong";
if (m instanceof MeshLambertMaterial) type = "lambert";
else if (m instanceof MeshBasicMaterial) {
type = "constant";
if (m.map !== null) console.warn("ColladaExporter: Texture maps not supported with MeshBasicMaterial.");
}
if (m instanceof MeshPhongMaterial) {
const emissive = m.emissive ? m.emissive : new Color(0, 0, 0);
const diffuse = m.color ? m.color : new Color(0, 0, 0);
const specular = m.specular ? m.specular : new Color(1, 1, 1);
const shininess = m.shininess || 0;
const reflectivity = m.reflectivity || 0;
let transparencyNode = "";
if (m.transparent) {
transparencyNode += `${m.map ? "" : "1"}`;
if (m.opacity < 1) transparencyNode += `${m.opacity}`;
}
const techniqueNode = `${`<${type}>`}${m.emissiveMap ? "" : `${emissive.r} ${emissive.g} ${emissive.b} 1`}${type !== "constant" ? `${m.map ? "" : `${diffuse.r} ${diffuse.g} ${diffuse.b} 1`}` : ""}${type !== "constant" ? `${m.normalMap ? "" : ""}` : ""}${type === "phong" ? `${`${specular.r} ${specular.g} ${specular.b} 1`}${m.specularMap ? "" : `${shininess}`}` : ""}${`${diffuse.r} ${diffuse.g} ${diffuse.b} 1`}${`${reflectivity}`}${transparencyNode}${`${type}>`}`;
const effectnode = `${``}${m.map ? `${`${this.processTexture(m.map)}`}diffuse-surface` : ""}${m.specularMap ? `${`${this.processTexture(m.specularMap)}`}specular-surface` : ""}${m.emissiveMap ? `${`${this.processTexture(m.emissiveMap)}`}emissive-surface` : ""}${m.normalMap ? `${`${this.processTexture(m.normalMap)}`}bump-surface` : ""}${techniqueNode}${m.side === 2 ? "1" : ""}`;
const materialName = m.name ? ` name="${m.name}"` : "";
const materialNode = ``;
this.libraryMaterials.push(materialNode);
this.libraryEffects.push(effectnode);
this.materialMap.set(m, matid);
}
}
return matid;
}
processObject(o) {
let node = ``;
node += this.getTransform(o);
new Mesh().geometry;
if (o instanceof Mesh && o.isMesh && o.geometry !== null) {
const geomInfo = this.processGeometry(o.geometry);
const meshid = geomInfo.meshid;
const geometry = geomInfo.bufferGeometry;
let matids = null;
let matidsArray;
const mat = o.material || new MeshBasicMaterial();
const materials = Array.isArray(mat) ? mat : [mat];
if (geometry.groups.length > materials.length) matidsArray = new Array(geometry.groups.length);
else matidsArray = new Array(materials.length);
matids = matidsArray.fill(null).map((_, i) => this.processMaterial(materials[i % materials.length]));
node += `${`` + (matids != null ? `${matids.map((id, i) => `${``}`).join("")}` : "")}`;
}
o.children.forEach((c) => node += this.processObject(c));
node += "";
return node;
}
};
//#endregion
//#region node_modules/three-stdlib/libs/mmdparser.js
var CharsetEncoder = class {
constructor() {
this.s2uTable = {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
10: 10,
11: 11,
12: 12,
13: 13,
14: 14,
15: 15,
16: 16,
17: 17,
18: 18,
19: 19,
20: 20,
21: 21,
22: 22,
23: 23,
24: 24,
25: 25,
26: 26,
27: 27,
28: 28,
29: 29,
30: 30,
31: 31,
32: 32,
33: 33,
34: 34,
35: 35,
36: 36,
37: 37,
38: 38,
39: 39,
40: 40,
41: 41,
42: 42,
43: 43,
44: 44,
45: 45,
46: 46,
47: 47,
48: 48,
49: 49,
50: 50,
51: 51,
52: 52,
53: 53,
54: 54,
55: 55,
56: 56,
57: 57,
58: 58,
59: 59,
60: 60,
61: 61,
62: 62,
63: 63,
64: 64,
65: 65,
66: 66,
67: 67,
68: 68,
69: 69,
70: 70,
71: 71,
72: 72,
73: 73,
74: 74,
75: 75,
76: 76,
77: 77,
78: 78,
79: 79,
80: 80,
81: 81,
82: 82,
83: 83,
84: 84,
85: 85,
86: 86,
87: 87,
88: 88,
89: 89,
90: 90,
91: 91,
92: 92,
93: 93,
94: 94,
95: 95,
96: 96,
97: 97,
98: 98,
99: 99,
100: 100,
101: 101,
102: 102,
103: 103,
104: 104,
105: 105,
106: 106,
107: 107,
108: 108,
109: 109,
110: 110,
111: 111,
112: 112,
113: 113,
114: 114,
115: 115,
116: 116,
117: 117,
118: 118,
119: 119,
120: 120,
121: 121,
122: 122,
123: 123,
124: 124,
125: 125,
126: 126,
161: 65377,
162: 65378,
163: 65379,
164: 65380,
165: 65381,
166: 65382,
167: 65383,
168: 65384,
169: 65385,
170: 65386,
171: 65387,
172: 65388,
173: 65389,
174: 65390,
175: 65391,
176: 65392,
177: 65393,
178: 65394,
179: 65395,
180: 65396,
181: 65397,
182: 65398,
183: 65399,
184: 65400,
185: 65401,
186: 65402,
187: 65403,
188: 65404,
189: 65405,
190: 65406,
191: 65407,
192: 65408,
193: 65409,
194: 65410,
195: 65411,
196: 65412,
197: 65413,
198: 65414,
199: 65415,
200: 65416,
201: 65417,
202: 65418,
203: 65419,
204: 65420,
205: 65421,
206: 65422,
207: 65423,
208: 65424,
209: 65425,
210: 65426,
211: 65427,
212: 65428,
213: 65429,
214: 65430,
215: 65431,
216: 65432,
217: 65433,
218: 65434,
219: 65435,
220: 65436,
221: 65437,
222: 65438,
223: 65439,
33088: 12288,
33089: 12289,
33090: 12290,
33091: 65292,
33092: 65294,
33093: 12539,
33094: 65306,
33095: 65307,
33096: 65311,
33097: 65281,
33098: 12443,
33099: 12444,
33100: 180,
33101: 65344,
33102: 168,
33103: 65342,
33104: 65507,
33105: 65343,
33106: 12541,
33107: 12542,
33108: 12445,
33109: 12446,
33110: 12291,
33111: 20189,
33112: 12293,
33113: 12294,
33114: 12295,
33115: 12540,
33116: 8213,
33117: 8208,
33118: 65295,
33119: 65340,
33120: 65374,
33121: 8741,
33122: 65372,
33123: 8230,
33124: 8229,
33125: 8216,
33126: 8217,
33127: 8220,
33128: 8221,
33129: 65288,
33130: 65289,
33131: 12308,
33132: 12309,
33133: 65339,
33134: 65341,
33135: 65371,
33136: 65373,
33137: 12296,
33138: 12297,
33139: 12298,
33140: 12299,
33141: 12300,
33142: 12301,
33143: 12302,
33144: 12303,
33145: 12304,
33146: 12305,
33147: 65291,
33148: 65293,
33149: 177,
33150: 215,
33152: 247,
33153: 65309,
33154: 8800,
33155: 65308,
33156: 65310,
33157: 8806,
33158: 8807,
33159: 8734,
33160: 8756,
33161: 9794,
33162: 9792,
33163: 176,
33164: 8242,
33165: 8243,
33166: 8451,
33167: 65509,
33168: 65284,
33169: 65504,
33170: 65505,
33171: 65285,
33172: 65283,
33173: 65286,
33174: 65290,
33175: 65312,
33176: 167,
33177: 9734,
33178: 9733,
33179: 9675,
33180: 9679,
33181: 9678,
33182: 9671,
33183: 9670,
33184: 9633,
33185: 9632,
33186: 9651,
33187: 9650,
33188: 9661,
33189: 9660,
33190: 8251,
33191: 12306,
33192: 8594,
33193: 8592,
33194: 8593,
33195: 8595,
33196: 12307,
33208: 8712,
33209: 8715,
33210: 8838,
33211: 8839,
33212: 8834,
33213: 8835,
33214: 8746,
33215: 8745,
33224: 8743,
33225: 8744,
33226: 65506,
33227: 8658,
33228: 8660,
33229: 8704,
33230: 8707,
33242: 8736,
33243: 8869,
33244: 8978,
33245: 8706,
33246: 8711,
33247: 8801,
33248: 8786,
33249: 8810,
33250: 8811,
33251: 8730,
33252: 8765,
33253: 8733,
33254: 8757,
33255: 8747,
33256: 8748,
33264: 8491,
33265: 8240,
33266: 9839,
33267: 9837,
33268: 9834,
33269: 8224,
33270: 8225,
33271: 182,
33276: 9711,
33359: 65296,
33360: 65297,
33361: 65298,
33362: 65299,
33363: 65300,
33364: 65301,
33365: 65302,
33366: 65303,
33367: 65304,
33368: 65305,
33376: 65313,
33377: 65314,
33378: 65315,
33379: 65316,
33380: 65317,
33381: 65318,
33382: 65319,
33383: 65320,
33384: 65321,
33385: 65322,
33386: 65323,
33387: 65324,
33388: 65325,
33389: 65326,
33390: 65327,
33391: 65328,
33392: 65329,
33393: 65330,
33394: 65331,
33395: 65332,
33396: 65333,
33397: 65334,
33398: 65335,
33399: 65336,
33400: 65337,
33401: 65338,
33409: 65345,
33410: 65346,
33411: 65347,
33412: 65348,
33413: 65349,
33414: 65350,
33415: 65351,
33416: 65352,
33417: 65353,
33418: 65354,
33419: 65355,
33420: 65356,
33421: 65357,
33422: 65358,
33423: 65359,
33424: 65360,
33425: 65361,
33426: 65362,
33427: 65363,
33428: 65364,
33429: 65365,
33430: 65366,
33431: 65367,
33432: 65368,
33433: 65369,
33434: 65370,
33439: 12353,
33440: 12354,
33441: 12355,
33442: 12356,
33443: 12357,
33444: 12358,
33445: 12359,
33446: 12360,
33447: 12361,
33448: 12362,
33449: 12363,
33450: 12364,
33451: 12365,
33452: 12366,
33453: 12367,
33454: 12368,
33455: 12369,
33456: 12370,
33457: 12371,
33458: 12372,
33459: 12373,
33460: 12374,
33461: 12375,
33462: 12376,
33463: 12377,
33464: 12378,
33465: 12379,
33466: 12380,
33467: 12381,
33468: 12382,
33469: 12383,
33470: 12384,
33471: 12385,
33472: 12386,
33473: 12387,
33474: 12388,
33475: 12389,
33476: 12390,
33477: 12391,
33478: 12392,
33479: 12393,
33480: 12394,
33481: 12395,
33482: 12396,
33483: 12397,
33484: 12398,
33485: 12399,
33486: 12400,
33487: 12401,
33488: 12402,
33489: 12403,
33490: 12404,
33491: 12405,
33492: 12406,
33493: 12407,
33494: 12408,
33495: 12409,
33496: 12410,
33497: 12411,
33498: 12412,
33499: 12413,
33500: 12414,
33501: 12415,
33502: 12416,
33503: 12417,
33504: 12418,
33505: 12419,
33506: 12420,
33507: 12421,
33508: 12422,
33509: 12423,
33510: 12424,
33511: 12425,
33512: 12426,
33513: 12427,
33514: 12428,
33515: 12429,
33516: 12430,
33517: 12431,
33518: 12432,
33519: 12433,
33520: 12434,
33521: 12435,
33600: 12449,
33601: 12450,
33602: 12451,
33603: 12452,
33604: 12453,
33605: 12454,
33606: 12455,
33607: 12456,
33608: 12457,
33609: 12458,
33610: 12459,
33611: 12460,
33612: 12461,
33613: 12462,
33614: 12463,
33615: 12464,
33616: 12465,
33617: 12466,
33618: 12467,
33619: 12468,
33620: 12469,
33621: 12470,
33622: 12471,
33623: 12472,
33624: 12473,
33625: 12474,
33626: 12475,
33627: 12476,
33628: 12477,
33629: 12478,
33630: 12479,
33631: 12480,
33632: 12481,
33633: 12482,
33634: 12483,
33635: 12484,
33636: 12485,
33637: 12486,
33638: 12487,
33639: 12488,
33640: 12489,
33641: 12490,
33642: 12491,
33643: 12492,
33644: 12493,
33645: 12494,
33646: 12495,
33647: 12496,
33648: 12497,
33649: 12498,
33650: 12499,
33651: 12500,
33652: 12501,
33653: 12502,
33654: 12503,
33655: 12504,
33656: 12505,
33657: 12506,
33658: 12507,
33659: 12508,
33660: 12509,
33661: 12510,
33662: 12511,
33664: 12512,
33665: 12513,
33666: 12514,
33667: 12515,
33668: 12516,
33669: 12517,
33670: 12518,
33671: 12519,
33672: 12520,
33673: 12521,
33674: 12522,
33675: 12523,
33676: 12524,
33677: 12525,
33678: 12526,
33679: 12527,
33680: 12528,
33681: 12529,
33682: 12530,
33683: 12531,
33684: 12532,
33685: 12533,
33686: 12534,
33695: 913,
33696: 914,
33697: 915,
33698: 916,
33699: 917,
33700: 918,
33701: 919,
33702: 920,
33703: 921,
33704: 922,
33705: 923,
33706: 924,
33707: 925,
33708: 926,
33709: 927,
33710: 928,
33711: 929,
33712: 931,
33713: 932,
33714: 933,
33715: 934,
33716: 935,
33717: 936,
33718: 937,
33727: 945,
33728: 946,
33729: 947,
33730: 948,
33731: 949,
33732: 950,
33733: 951,
33734: 952,
33735: 953,
33736: 954,
33737: 955,
33738: 956,
33739: 957,
33740: 958,
33741: 959,
33742: 960,
33743: 961,
33744: 963,
33745: 964,
33746: 965,
33747: 966,
33748: 967,
33749: 968,
33750: 969,
33856: 1040,
33857: 1041,
33858: 1042,
33859: 1043,
33860: 1044,
33861: 1045,
33862: 1025,
33863: 1046,
33864: 1047,
33865: 1048,
33866: 1049,
33867: 1050,
33868: 1051,
33869: 1052,
33870: 1053,
33871: 1054,
33872: 1055,
33873: 1056,
33874: 1057,
33875: 1058,
33876: 1059,
33877: 1060,
33878: 1061,
33879: 1062,
33880: 1063,
33881: 1064,
33882: 1065,
33883: 1066,
33884: 1067,
33885: 1068,
33886: 1069,
33887: 1070,
33888: 1071,
33904: 1072,
33905: 1073,
33906: 1074,
33907: 1075,
33908: 1076,
33909: 1077,
33910: 1105,
33911: 1078,
33912: 1079,
33913: 1080,
33914: 1081,
33915: 1082,
33916: 1083,
33917: 1084,
33918: 1085,
33920: 1086,
33921: 1087,
33922: 1088,
33923: 1089,
33924: 1090,
33925: 1091,
33926: 1092,
33927: 1093,
33928: 1094,
33929: 1095,
33930: 1096,
33931: 1097,
33932: 1098,
33933: 1099,
33934: 1100,
33935: 1101,
33936: 1102,
33937: 1103,
33951: 9472,
33952: 9474,
33953: 9484,
33954: 9488,
33955: 9496,
33956: 9492,
33957: 9500,
33958: 9516,
33959: 9508,
33960: 9524,
33961: 9532,
33962: 9473,
33963: 9475,
33964: 9487,
33965: 9491,
33966: 9499,
33967: 9495,
33968: 9507,
33969: 9523,
33970: 9515,
33971: 9531,
33972: 9547,
33973: 9504,
33974: 9519,
33975: 9512,
33976: 9527,
33977: 9535,
33978: 9501,
33979: 9520,
33980: 9509,
33981: 9528,
33982: 9538,
34624: 9312,
34625: 9313,
34626: 9314,
34627: 9315,
34628: 9316,
34629: 9317,
34630: 9318,
34631: 9319,
34632: 9320,
34633: 9321,
34634: 9322,
34635: 9323,
34636: 9324,
34637: 9325,
34638: 9326,
34639: 9327,
34640: 9328,
34641: 9329,
34642: 9330,
34643: 9331,
34644: 8544,
34645: 8545,
34646: 8546,
34647: 8547,
34648: 8548,
34649: 8549,
34650: 8550,
34651: 8551,
34652: 8552,
34653: 8553,
34655: 13129,
34656: 13076,
34657: 13090,
34658: 13133,
34659: 13080,
34660: 13095,
34661: 13059,
34662: 13110,
34663: 13137,
34664: 13143,
34665: 13069,
34666: 13094,
34667: 13091,
34668: 13099,
34669: 13130,
34670: 13115,
34671: 13212,
34672: 13213,
34673: 13214,
34674: 13198,
34675: 13199,
34676: 13252,
34677: 13217,
34686: 13179,
34688: 12317,
34689: 12319,
34690: 8470,
34691: 13261,
34692: 8481,
34693: 12964,
34694: 12965,
34695: 12966,
34696: 12967,
34697: 12968,
34698: 12849,
34699: 12850,
34700: 12857,
34701: 13182,
34702: 13181,
34703: 13180,
34704: 8786,
34705: 8801,
34706: 8747,
34707: 8750,
34708: 8721,
34709: 8730,
34710: 8869,
34711: 8736,
34712: 8735,
34713: 8895,
34714: 8757,
34715: 8745,
34716: 8746,
34975: 20124,
34976: 21782,
34977: 23043,
34978: 38463,
34979: 21696,
34980: 24859,
34981: 25384,
34982: 23030,
34983: 36898,
34984: 33909,
34985: 33564,
34986: 31312,
34987: 24746,
34988: 25569,
34989: 28197,
34990: 26093,
34991: 33894,
34992: 33446,
34993: 39925,
34994: 26771,
34995: 22311,
34996: 26017,
34997: 25201,
34998: 23451,
34999: 22992,
35e3: 34427,
35001: 39156,
35002: 32098,
35003: 32190,
35004: 39822,
35005: 25110,
35006: 31903,
35007: 34999,
35008: 23433,
35009: 24245,
35010: 25353,
35011: 26263,
35012: 26696,
35013: 38343,
35014: 38797,
35015: 26447,
35016: 20197,
35017: 20234,
35018: 20301,
35019: 20381,
35020: 20553,
35021: 22258,
35022: 22839,
35023: 22996,
35024: 23041,
35025: 23561,
35026: 24799,
35027: 24847,
35028: 24944,
35029: 26131,
35030: 26885,
35031: 28858,
35032: 30031,
35033: 30064,
35034: 31227,
35035: 32173,
35036: 32239,
35037: 32963,
35038: 33806,
35039: 34915,
35040: 35586,
35041: 36949,
35042: 36986,
35043: 21307,
35044: 20117,
35045: 20133,
35046: 22495,
35047: 32946,
35048: 37057,
35049: 30959,
35050: 19968,
35051: 22769,
35052: 28322,
35053: 36920,
35054: 31282,
35055: 33576,
35056: 33419,
35057: 39983,
35058: 20801,
35059: 21360,
35060: 21693,
35061: 21729,
35062: 22240,
35063: 23035,
35064: 24341,
35065: 39154,
35066: 28139,
35067: 32996,
35068: 34093,
35136: 38498,
35137: 38512,
35138: 38560,
35139: 38907,
35140: 21515,
35141: 21491,
35142: 23431,
35143: 28879,
35144: 32701,
35145: 36802,
35146: 38632,
35147: 21359,
35148: 40284,
35149: 31418,
35150: 19985,
35151: 30867,
35152: 33276,
35153: 28198,
35154: 22040,
35155: 21764,
35156: 27421,
35157: 34074,
35158: 39995,
35159: 23013,
35160: 21417,
35161: 28006,
35162: 29916,
35163: 38287,
35164: 22082,
35165: 20113,
35166: 36939,
35167: 38642,
35168: 33615,
35169: 39180,
35170: 21473,
35171: 21942,
35172: 23344,
35173: 24433,
35174: 26144,
35175: 26355,
35176: 26628,
35177: 27704,
35178: 27891,
35179: 27945,
35180: 29787,
35181: 30408,
35182: 31310,
35183: 38964,
35184: 33521,
35185: 34907,
35186: 35424,
35187: 37613,
35188: 28082,
35189: 30123,
35190: 30410,
35191: 39365,
35192: 24742,
35193: 35585,
35194: 36234,
35195: 38322,
35196: 27022,
35197: 21421,
35198: 20870,
35200: 22290,
35201: 22576,
35202: 22852,
35203: 23476,
35204: 24310,
35205: 24616,
35206: 25513,
35207: 25588,
35208: 27839,
35209: 28436,
35210: 28814,
35211: 28948,
35212: 29017,
35213: 29141,
35214: 29503,
35215: 32257,
35216: 33398,
35217: 33489,
35218: 34199,
35219: 36960,
35220: 37467,
35221: 40219,
35222: 22633,
35223: 26044,
35224: 27738,
35225: 29989,
35226: 20985,
35227: 22830,
35228: 22885,
35229: 24448,
35230: 24540,
35231: 25276,
35232: 26106,
35233: 27178,
35234: 27431,
35235: 27572,
35236: 29579,
35237: 32705,
35238: 35158,
35239: 40236,
35240: 40206,
35241: 40644,
35242: 23713,
35243: 27798,
35244: 33659,
35245: 20740,
35246: 23627,
35247: 25014,
35248: 33222,
35249: 26742,
35250: 29281,
35251: 20057,
35252: 20474,
35253: 21368,
35254: 24681,
35255: 28201,
35256: 31311,
35257: 38899,
35258: 19979,
35259: 21270,
35260: 20206,
35261: 20309,
35262: 20285,
35263: 20385,
35264: 20339,
35265: 21152,
35266: 21487,
35267: 22025,
35268: 22799,
35269: 23233,
35270: 23478,
35271: 23521,
35272: 31185,
35273: 26247,
35274: 26524,
35275: 26550,
35276: 27468,
35277: 27827,
35278: 28779,
35279: 29634,
35280: 31117,
35281: 31166,
35282: 31292,
35283: 31623,
35284: 33457,
35285: 33499,
35286: 33540,
35287: 33655,
35288: 33775,
35289: 33747,
35290: 34662,
35291: 35506,
35292: 22057,
35293: 36008,
35294: 36838,
35295: 36942,
35296: 38686,
35297: 34442,
35298: 20420,
35299: 23784,
35300: 25105,
35301: 29273,
35302: 30011,
35303: 33253,
35304: 33469,
35305: 34558,
35306: 36032,
35307: 38597,
35308: 39187,
35309: 39381,
35310: 20171,
35311: 20250,
35312: 35299,
35313: 22238,
35314: 22602,
35315: 22730,
35316: 24315,
35317: 24555,
35318: 24618,
35319: 24724,
35320: 24674,
35321: 25040,
35322: 25106,
35323: 25296,
35324: 25913,
35392: 39745,
35393: 26214,
35394: 26800,
35395: 28023,
35396: 28784,
35397: 30028,
35398: 30342,
35399: 32117,
35400: 33445,
35401: 34809,
35402: 38283,
35403: 38542,
35404: 35997,
35405: 20977,
35406: 21182,
35407: 22806,
35408: 21683,
35409: 23475,
35410: 23830,
35411: 24936,
35412: 27010,
35413: 28079,
35414: 30861,
35415: 33995,
35416: 34903,
35417: 35442,
35418: 37799,
35419: 39608,
35420: 28012,
35421: 39336,
35422: 34521,
35423: 22435,
35424: 26623,
35425: 34510,
35426: 37390,
35427: 21123,
35428: 22151,
35429: 21508,
35430: 24275,
35431: 25313,
35432: 25785,
35433: 26684,
35434: 26680,
35435: 27579,
35436: 29554,
35437: 30906,
35438: 31339,
35439: 35226,
35440: 35282,
35441: 36203,
35442: 36611,
35443: 37101,
35444: 38307,
35445: 38548,
35446: 38761,
35447: 23398,
35448: 23731,
35449: 27005,
35450: 38989,
35451: 38990,
35452: 25499,
35453: 31520,
35454: 27179,
35456: 27263,
35457: 26806,
35458: 39949,
35459: 28511,
35460: 21106,
35461: 21917,
35462: 24688,
35463: 25324,
35464: 27963,
35465: 28167,
35466: 28369,
35467: 33883,
35468: 35088,
35469: 36676,
35470: 19988,
35471: 39993,
35472: 21494,
35473: 26907,
35474: 27194,
35475: 38788,
35476: 26666,
35477: 20828,
35478: 31427,
35479: 33970,
35480: 37340,
35481: 37772,
35482: 22107,
35483: 40232,
35484: 26658,
35485: 33541,
35486: 33841,
35487: 31909,
35488: 21e3,
35489: 33477,
35490: 29926,
35491: 20094,
35492: 20355,
35493: 20896,
35494: 23506,
35495: 21002,
35496: 21208,
35497: 21223,
35498: 24059,
35499: 21914,
35500: 22570,
35501: 23014,
35502: 23436,
35503: 23448,
35504: 23515,
35505: 24178,
35506: 24185,
35507: 24739,
35508: 24863,
35509: 24931,
35510: 25022,
35511: 25563,
35512: 25954,
35513: 26577,
35514: 26707,
35515: 26874,
35516: 27454,
35517: 27475,
35518: 27735,
35519: 28450,
35520: 28567,
35521: 28485,
35522: 29872,
35523: 29976,
35524: 30435,
35525: 30475,
35526: 31487,
35527: 31649,
35528: 31777,
35529: 32233,
35530: 32566,
35531: 32752,
35532: 32925,
35533: 33382,
35534: 33694,
35535: 35251,
35536: 35532,
35537: 36011,
35538: 36996,
35539: 37969,
35540: 38291,
35541: 38289,
35542: 38306,
35543: 38501,
35544: 38867,
35545: 39208,
35546: 33304,
35547: 20024,
35548: 21547,
35549: 23736,
35550: 24012,
35551: 29609,
35552: 30284,
35553: 30524,
35554: 23721,
35555: 32747,
35556: 36107,
35557: 38593,
35558: 38929,
35559: 38996,
35560: 39e3,
35561: 20225,
35562: 20238,
35563: 21361,
35564: 21916,
35565: 22120,
35566: 22522,
35567: 22855,
35568: 23305,
35569: 23492,
35570: 23696,
35571: 24076,
35572: 24190,
35573: 24524,
35574: 25582,
35575: 26426,
35576: 26071,
35577: 26082,
35578: 26399,
35579: 26827,
35580: 26820,
35648: 27231,
35649: 24112,
35650: 27589,
35651: 27671,
35652: 27773,
35653: 30079,
35654: 31048,
35655: 23395,
35656: 31232,
35657: 32e3,
35658: 24509,
35659: 35215,
35660: 35352,
35661: 36020,
35662: 36215,
35663: 36556,
35664: 36637,
35665: 39138,
35666: 39438,
35667: 39740,
35668: 20096,
35669: 20605,
35670: 20736,
35671: 22931,
35672: 23452,
35673: 25135,
35674: 25216,
35675: 25836,
35676: 27450,
35677: 29344,
35678: 30097,
35679: 31047,
35680: 32681,
35681: 34811,
35682: 35516,
35683: 35696,
35684: 25516,
35685: 33738,
35686: 38816,
35687: 21513,
35688: 21507,
35689: 21931,
35690: 26708,
35691: 27224,
35692: 35440,
35693: 30759,
35694: 26485,
35695: 40653,
35696: 21364,
35697: 23458,
35698: 33050,
35699: 34384,
35700: 36870,
35701: 19992,
35702: 20037,
35703: 20167,
35704: 20241,
35705: 21450,
35706: 21560,
35707: 23470,
35708: 24339,
35709: 24613,
35710: 25937,
35712: 26429,
35713: 27714,
35714: 27762,
35715: 27875,
35716: 28792,
35717: 29699,
35718: 31350,
35719: 31406,
35720: 31496,
35721: 32026,
35722: 31998,
35723: 32102,
35724: 26087,
35725: 29275,
35726: 21435,
35727: 23621,
35728: 24040,
35729: 25298,
35730: 25312,
35731: 25369,
35732: 28192,
35733: 34394,
35734: 35377,
35735: 36317,
35736: 37624,
35737: 28417,
35738: 31142,
35739: 39770,
35740: 20136,
35741: 20139,
35742: 20140,
35743: 20379,
35744: 20384,
35745: 20689,
35746: 20807,
35747: 31478,
35748: 20849,
35749: 20982,
35750: 21332,
35751: 21281,
35752: 21375,
35753: 21483,
35754: 21932,
35755: 22659,
35756: 23777,
35757: 24375,
35758: 24394,
35759: 24623,
35760: 24656,
35761: 24685,
35762: 25375,
35763: 25945,
35764: 27211,
35765: 27841,
35766: 29378,
35767: 29421,
35768: 30703,
35769: 33016,
35770: 33029,
35771: 33288,
35772: 34126,
35773: 37111,
35774: 37857,
35775: 38911,
35776: 39255,
35777: 39514,
35778: 20208,
35779: 20957,
35780: 23597,
35781: 26241,
35782: 26989,
35783: 23616,
35784: 26354,
35785: 26997,
35786: 29577,
35787: 26704,
35788: 31873,
35789: 20677,
35790: 21220,
35791: 22343,
35792: 24062,
35793: 37670,
35794: 26020,
35795: 27427,
35796: 27453,
35797: 29748,
35798: 31105,
35799: 31165,
35800: 31563,
35801: 32202,
35802: 33465,
35803: 33740,
35804: 34943,
35805: 35167,
35806: 35641,
35807: 36817,
35808: 37329,
35809: 21535,
35810: 37504,
35811: 20061,
35812: 20534,
35813: 21477,
35814: 21306,
35815: 29399,
35816: 29590,
35817: 30697,
35818: 33510,
35819: 36527,
35820: 39366,
35821: 39368,
35822: 39378,
35823: 20855,
35824: 24858,
35825: 34398,
35826: 21936,
35827: 31354,
35828: 20598,
35829: 23507,
35830: 36935,
35831: 38533,
35832: 20018,
35833: 27355,
35834: 37351,
35835: 23633,
35836: 23624,
35904: 25496,
35905: 31391,
35906: 27795,
35907: 38772,
35908: 36705,
35909: 31402,
35910: 29066,
35911: 38536,
35912: 31874,
35913: 26647,
35914: 32368,
35915: 26705,
35916: 37740,
35917: 21234,
35918: 21531,
35919: 34219,
35920: 35347,
35921: 32676,
35922: 36557,
35923: 37089,
35924: 21350,
35925: 34952,
35926: 31041,
35927: 20418,
35928: 20670,
35929: 21009,
35930: 20804,
35931: 21843,
35932: 22317,
35933: 29674,
35934: 22411,
35935: 22865,
35936: 24418,
35937: 24452,
35938: 24693,
35939: 24950,
35940: 24935,
35941: 25001,
35942: 25522,
35943: 25658,
35944: 25964,
35945: 26223,
35946: 26690,
35947: 28179,
35948: 30054,
35949: 31293,
35950: 31995,
35951: 32076,
35952: 32153,
35953: 32331,
35954: 32619,
35955: 33550,
35956: 33610,
35957: 34509,
35958: 35336,
35959: 35427,
35960: 35686,
35961: 36605,
35962: 38938,
35963: 40335,
35964: 33464,
35965: 36814,
35966: 39912,
35968: 21127,
35969: 25119,
35970: 25731,
35971: 28608,
35972: 38553,
35973: 26689,
35974: 20625,
35975: 27424,
35976: 27770,
35977: 28500,
35978: 31348,
35979: 32080,
35980: 34880,
35981: 35363,
35982: 26376,
35983: 20214,
35984: 20537,
35985: 20518,
35986: 20581,
35987: 20860,
35988: 21048,
35989: 21091,
35990: 21927,
35991: 22287,
35992: 22533,
35993: 23244,
35994: 24314,
35995: 25010,
35996: 25080,
35997: 25331,
35998: 25458,
35999: 26908,
36e3: 27177,
36001: 29309,
36002: 29356,
36003: 29486,
36004: 30740,
36005: 30831,
36006: 32121,
36007: 30476,
36008: 32937,
36009: 35211,
36010: 35609,
36011: 36066,
36012: 36562,
36013: 36963,
36014: 37749,
36015: 38522,
36016: 38997,
36017: 39443,
36018: 40568,
36019: 20803,
36020: 21407,
36021: 21427,
36022: 24187,
36023: 24358,
36024: 28187,
36025: 28304,
36026: 29572,
36027: 29694,
36028: 32067,
36029: 33335,
36030: 35328,
36031: 35578,
36032: 38480,
36033: 20046,
36034: 20491,
36035: 21476,
36036: 21628,
36037: 22266,
36038: 22993,
36039: 23396,
36040: 24049,
36041: 24235,
36042: 24359,
36043: 25144,
36044: 25925,
36045: 26543,
36046: 28246,
36047: 29392,
36048: 31946,
36049: 34996,
36050: 32929,
36051: 32993,
36052: 33776,
36053: 34382,
36054: 35463,
36055: 36328,
36056: 37431,
36057: 38599,
36058: 39015,
36059: 40723,
36060: 20116,
36061: 20114,
36062: 20237,
36063: 21320,
36064: 21577,
36065: 21566,
36066: 23087,
36067: 24460,
36068: 24481,
36069: 24735,
36070: 26791,
36071: 27278,
36072: 29786,
36073: 30849,
36074: 35486,
36075: 35492,
36076: 35703,
36077: 37264,
36078: 20062,
36079: 39881,
36080: 20132,
36081: 20348,
36082: 20399,
36083: 20505,
36084: 20502,
36085: 20809,
36086: 20844,
36087: 21151,
36088: 21177,
36089: 21246,
36090: 21402,
36091: 21475,
36092: 21521,
36160: 21518,
36161: 21897,
36162: 22353,
36163: 22434,
36164: 22909,
36165: 23380,
36166: 23389,
36167: 23439,
36168: 24037,
36169: 24039,
36170: 24055,
36171: 24184,
36172: 24195,
36173: 24218,
36174: 24247,
36175: 24344,
36176: 24658,
36177: 24908,
36178: 25239,
36179: 25304,
36180: 25511,
36181: 25915,
36182: 26114,
36183: 26179,
36184: 26356,
36185: 26477,
36186: 26657,
36187: 26775,
36188: 27083,
36189: 27743,
36190: 27946,
36191: 28009,
36192: 28207,
36193: 28317,
36194: 30002,
36195: 30343,
36196: 30828,
36197: 31295,
36198: 31968,
36199: 32005,
36200: 32024,
36201: 32094,
36202: 32177,
36203: 32789,
36204: 32771,
36205: 32943,
36206: 32945,
36207: 33108,
36208: 33167,
36209: 33322,
36210: 33618,
36211: 34892,
36212: 34913,
36213: 35611,
36214: 36002,
36215: 36092,
36216: 37066,
36217: 37237,
36218: 37489,
36219: 30783,
36220: 37628,
36221: 38308,
36222: 38477,
36224: 38917,
36225: 39321,
36226: 39640,
36227: 40251,
36228: 21083,
36229: 21163,
36230: 21495,
36231: 21512,
36232: 22741,
36233: 25335,
36234: 28640,
36235: 35946,
36236: 36703,
36237: 40633,
36238: 20811,
36239: 21051,
36240: 21578,
36241: 22269,
36242: 31296,
36243: 37239,
36244: 40288,
36245: 40658,
36246: 29508,
36247: 28425,
36248: 33136,
36249: 29969,
36250: 24573,
36251: 24794,
36252: 39592,
36253: 29403,
36254: 36796,
36255: 27492,
36256: 38915,
36257: 20170,
36258: 22256,
36259: 22372,
36260: 22718,
36261: 23130,
36262: 24680,
36263: 25031,
36264: 26127,
36265: 26118,
36266: 26681,
36267: 26801,
36268: 28151,
36269: 30165,
36270: 32058,
36271: 33390,
36272: 39746,
36273: 20123,
36274: 20304,
36275: 21449,
36276: 21766,
36277: 23919,
36278: 24038,
36279: 24046,
36280: 26619,
36281: 27801,
36282: 29811,
36283: 30722,
36284: 35408,
36285: 37782,
36286: 35039,
36287: 22352,
36288: 24231,
36289: 25387,
36290: 20661,
36291: 20652,
36292: 20877,
36293: 26368,
36294: 21705,
36295: 22622,
36296: 22971,
36297: 23472,
36298: 24425,
36299: 25165,
36300: 25505,
36301: 26685,
36302: 27507,
36303: 28168,
36304: 28797,
36305: 37319,
36306: 29312,
36307: 30741,
36308: 30758,
36309: 31085,
36310: 25998,
36311: 32048,
36312: 33756,
36313: 35009,
36314: 36617,
36315: 38555,
36316: 21092,
36317: 22312,
36318: 26448,
36319: 32618,
36320: 36001,
36321: 20916,
36322: 22338,
36323: 38442,
36324: 22586,
36325: 27018,
36326: 32948,
36327: 21682,
36328: 23822,
36329: 22524,
36330: 30869,
36331: 40442,
36332: 20316,
36333: 21066,
36334: 21643,
36335: 25662,
36336: 26152,
36337: 26388,
36338: 26613,
36339: 31364,
36340: 31574,
36341: 32034,
36342: 37679,
36343: 26716,
36344: 39853,
36345: 31545,
36346: 21273,
36347: 20874,
36348: 21047,
36416: 23519,
36417: 25334,
36418: 25774,
36419: 25830,
36420: 26413,
36421: 27578,
36422: 34217,
36423: 38609,
36424: 30352,
36425: 39894,
36426: 25420,
36427: 37638,
36428: 39851,
36429: 30399,
36430: 26194,
36431: 19977,
36432: 20632,
36433: 21442,
36434: 23665,
36435: 24808,
36436: 25746,
36437: 25955,
36438: 26719,
36439: 29158,
36440: 29642,
36441: 29987,
36442: 31639,
36443: 32386,
36444: 34453,
36445: 35715,
36446: 36059,
36447: 37240,
36448: 39184,
36449: 26028,
36450: 26283,
36451: 27531,
36452: 20181,
36453: 20180,
36454: 20282,
36455: 20351,
36456: 21050,
36457: 21496,
36458: 21490,
36459: 21987,
36460: 22235,
36461: 22763,
36462: 22987,
36463: 22985,
36464: 23039,
36465: 23376,
36466: 23629,
36467: 24066,
36468: 24107,
36469: 24535,
36470: 24605,
36471: 25351,
36472: 25903,
36473: 23388,
36474: 26031,
36475: 26045,
36476: 26088,
36477: 26525,
36478: 27490,
36480: 27515,
36481: 27663,
36482: 29509,
36483: 31049,
36484: 31169,
36485: 31992,
36486: 32025,
36487: 32043,
36488: 32930,
36489: 33026,
36490: 33267,
36491: 35222,
36492: 35422,
36493: 35433,
36494: 35430,
36495: 35468,
36496: 35566,
36497: 36039,
36498: 36060,
36499: 38604,
36500: 39164,
36501: 27503,
36502: 20107,
36503: 20284,
36504: 20365,
36505: 20816,
36506: 23383,
36507: 23546,
36508: 24904,
36509: 25345,
36510: 26178,
36511: 27425,
36512: 28363,
36513: 27835,
36514: 29246,
36515: 29885,
36516: 30164,
36517: 30913,
36518: 31034,
36519: 32780,
36520: 32819,
36521: 33258,
36522: 33940,
36523: 36766,
36524: 27728,
36525: 40575,
36526: 24335,
36527: 35672,
36528: 40235,
36529: 31482,
36530: 36600,
36531: 23437,
36532: 38635,
36533: 19971,
36534: 21489,
36535: 22519,
36536: 22833,
36537: 23241,
36538: 23460,
36539: 24713,
36540: 28287,
36541: 28422,
36542: 30142,
36543: 36074,
36544: 23455,
36545: 34048,
36546: 31712,
36547: 20594,
36548: 26612,
36549: 33437,
36550: 23649,
36551: 34122,
36552: 32286,
36553: 33294,
36554: 20889,
36555: 23556,
36556: 25448,
36557: 36198,
36558: 26012,
36559: 29038,
36560: 31038,
36561: 32023,
36562: 32773,
36563: 35613,
36564: 36554,
36565: 36974,
36566: 34503,
36567: 37034,
36568: 20511,
36569: 21242,
36570: 23610,
36571: 26451,
36572: 28796,
36573: 29237,
36574: 37196,
36575: 37320,
36576: 37675,
36577: 33509,
36578: 23490,
36579: 24369,
36580: 24825,
36581: 20027,
36582: 21462,
36583: 23432,
36584: 25163,
36585: 26417,
36586: 27530,
36587: 29417,
36588: 29664,
36589: 31278,
36590: 33131,
36591: 36259,
36592: 37202,
36593: 39318,
36594: 20754,
36595: 21463,
36596: 21610,
36597: 23551,
36598: 25480,
36599: 27193,
36600: 32172,
36601: 38656,
36602: 22234,
36603: 21454,
36604: 21608,
36672: 23447,
36673: 23601,
36674: 24030,
36675: 20462,
36676: 24833,
36677: 25342,
36678: 27954,
36679: 31168,
36680: 31179,
36681: 32066,
36682: 32333,
36683: 32722,
36684: 33261,
36685: 33311,
36686: 33936,
36687: 34886,
36688: 35186,
36689: 35728,
36690: 36468,
36691: 36655,
36692: 36913,
36693: 37195,
36694: 37228,
36695: 38598,
36696: 37276,
36697: 20160,
36698: 20303,
36699: 20805,
36700: 21313,
36701: 24467,
36702: 25102,
36703: 26580,
36704: 27713,
36705: 28171,
36706: 29539,
36707: 32294,
36708: 37325,
36709: 37507,
36710: 21460,
36711: 22809,
36712: 23487,
36713: 28113,
36714: 31069,
36715: 32302,
36716: 31899,
36717: 22654,
36718: 29087,
36719: 20986,
36720: 34899,
36721: 36848,
36722: 20426,
36723: 23803,
36724: 26149,
36725: 30636,
36726: 31459,
36727: 33308,
36728: 39423,
36729: 20934,
36730: 24490,
36731: 26092,
36732: 26991,
36733: 27529,
36734: 28147,
36736: 28310,
36737: 28516,
36738: 30462,
36739: 32020,
36740: 24033,
36741: 36981,
36742: 37255,
36743: 38918,
36744: 20966,
36745: 21021,
36746: 25152,
36747: 26257,
36748: 26329,
36749: 28186,
36750: 24246,
36751: 32210,
36752: 32626,
36753: 26360,
36754: 34223,
36755: 34295,
36756: 35576,
36757: 21161,
36758: 21465,
36759: 22899,
36760: 24207,
36761: 24464,
36762: 24661,
36763: 37604,
36764: 38500,
36765: 20663,
36766: 20767,
36767: 21213,
36768: 21280,
36769: 21319,
36770: 21484,
36771: 21736,
36772: 21830,
36773: 21809,
36774: 22039,
36775: 22888,
36776: 22974,
36777: 23100,
36778: 23477,
36779: 23558,
36780: 23567,
36781: 23569,
36782: 23578,
36783: 24196,
36784: 24202,
36785: 24288,
36786: 24432,
36787: 25215,
36788: 25220,
36789: 25307,
36790: 25484,
36791: 25463,
36792: 26119,
36793: 26124,
36794: 26157,
36795: 26230,
36796: 26494,
36797: 26786,
36798: 27167,
36799: 27189,
36800: 27836,
36801: 28040,
36802: 28169,
36803: 28248,
36804: 28988,
36805: 28966,
36806: 29031,
36807: 30151,
36808: 30465,
36809: 30813,
36810: 30977,
36811: 31077,
36812: 31216,
36813: 31456,
36814: 31505,
36815: 31911,
36816: 32057,
36817: 32918,
36818: 33750,
36819: 33931,
36820: 34121,
36821: 34909,
36822: 35059,
36823: 35359,
36824: 35388,
36825: 35412,
36826: 35443,
36827: 35937,
36828: 36062,
36829: 37284,
36830: 37478,
36831: 37758,
36832: 37912,
36833: 38556,
36834: 38808,
36835: 19978,
36836: 19976,
36837: 19998,
36838: 20055,
36839: 20887,
36840: 21104,
36841: 22478,
36842: 22580,
36843: 22732,
36844: 23330,
36845: 24120,
36846: 24773,
36847: 25854,
36848: 26465,
36849: 26454,
36850: 27972,
36851: 29366,
36852: 30067,
36853: 31331,
36854: 33976,
36855: 35698,
36856: 37304,
36857: 37664,
36858: 22065,
36859: 22516,
36860: 39166,
36928: 25325,
36929: 26893,
36930: 27542,
36931: 29165,
36932: 32340,
36933: 32887,
36934: 33394,
36935: 35302,
36936: 39135,
36937: 34645,
36938: 36785,
36939: 23611,
36940: 20280,
36941: 20449,
36942: 20405,
36943: 21767,
36944: 23072,
36945: 23517,
36946: 23529,
36947: 24515,
36948: 24910,
36949: 25391,
36950: 26032,
36951: 26187,
36952: 26862,
36953: 27035,
36954: 28024,
36955: 28145,
36956: 30003,
36957: 30137,
36958: 30495,
36959: 31070,
36960: 31206,
36961: 32051,
36962: 33251,
36963: 33455,
36964: 34218,
36965: 35242,
36966: 35386,
36967: 36523,
36968: 36763,
36969: 36914,
36970: 37341,
36971: 38663,
36972: 20154,
36973: 20161,
36974: 20995,
36975: 22645,
36976: 22764,
36977: 23563,
36978: 29978,
36979: 23613,
36980: 33102,
36981: 35338,
36982: 36805,
36983: 38499,
36984: 38765,
36985: 31525,
36986: 35535,
36987: 38920,
36988: 37218,
36989: 22259,
36990: 21416,
36992: 36887,
36993: 21561,
36994: 22402,
36995: 24101,
36996: 25512,
36997: 27700,
36998: 28810,
36999: 30561,
37e3: 31883,
37001: 32736,
37002: 34928,
37003: 36930,
37004: 37204,
37005: 37648,
37006: 37656,
37007: 38543,
37008: 29790,
37009: 39620,
37010: 23815,
37011: 23913,
37012: 25968,
37013: 26530,
37014: 36264,
37015: 38619,
37016: 25454,
37017: 26441,
37018: 26905,
37019: 33733,
37020: 38935,
37021: 38592,
37022: 35070,
37023: 28548,
37024: 25722,
37025: 23544,
37026: 19990,
37027: 28716,
37028: 30045,
37029: 26159,
37030: 20932,
37031: 21046,
37032: 21218,
37033: 22995,
37034: 24449,
37035: 24615,
37036: 25104,
37037: 25919,
37038: 25972,
37039: 26143,
37040: 26228,
37041: 26866,
37042: 26646,
37043: 27491,
37044: 28165,
37045: 29298,
37046: 29983,
37047: 30427,
37048: 31934,
37049: 32854,
37050: 22768,
37051: 35069,
37052: 35199,
37053: 35488,
37054: 35475,
37055: 35531,
37056: 36893,
37057: 37266,
37058: 38738,
37059: 38745,
37060: 25993,
37061: 31246,
37062: 33030,
37063: 38587,
37064: 24109,
37065: 24796,
37066: 25114,
37067: 26021,
37068: 26132,
37069: 26512,
37070: 30707,
37071: 31309,
37072: 31821,
37073: 32318,
37074: 33034,
37075: 36012,
37076: 36196,
37077: 36321,
37078: 36447,
37079: 30889,
37080: 20999,
37081: 25305,
37082: 25509,
37083: 25666,
37084: 25240,
37085: 35373,
37086: 31363,
37087: 31680,
37088: 35500,
37089: 38634,
37090: 32118,
37091: 33292,
37092: 34633,
37093: 20185,
37094: 20808,
37095: 21315,
37096: 21344,
37097: 23459,
37098: 23554,
37099: 23574,
37100: 24029,
37101: 25126,
37102: 25159,
37103: 25776,
37104: 26643,
37105: 26676,
37106: 27849,
37107: 27973,
37108: 27927,
37109: 26579,
37110: 28508,
37111: 29006,
37112: 29053,
37113: 26059,
37114: 31359,
37115: 31661,
37116: 32218,
37184: 32330,
37185: 32680,
37186: 33146,
37187: 33307,
37188: 33337,
37189: 34214,
37190: 35438,
37191: 36046,
37192: 36341,
37193: 36984,
37194: 36983,
37195: 37549,
37196: 37521,
37197: 38275,
37198: 39854,
37199: 21069,
37200: 21892,
37201: 28472,
37202: 28982,
37203: 20840,
37204: 31109,
37205: 32341,
37206: 33203,
37207: 31950,
37208: 22092,
37209: 22609,
37210: 23720,
37211: 25514,
37212: 26366,
37213: 26365,
37214: 26970,
37215: 29401,
37216: 30095,
37217: 30094,
37218: 30990,
37219: 31062,
37220: 31199,
37221: 31895,
37222: 32032,
37223: 32068,
37224: 34311,
37225: 35380,
37226: 38459,
37227: 36961,
37228: 40736,
37229: 20711,
37230: 21109,
37231: 21452,
37232: 21474,
37233: 20489,
37234: 21930,
37235: 22766,
37236: 22863,
37237: 29245,
37238: 23435,
37239: 23652,
37240: 21277,
37241: 24803,
37242: 24819,
37243: 25436,
37244: 25475,
37245: 25407,
37246: 25531,
37248: 25805,
37249: 26089,
37250: 26361,
37251: 24035,
37252: 27085,
37253: 27133,
37254: 28437,
37255: 29157,
37256: 20105,
37257: 30185,
37258: 30456,
37259: 31379,
37260: 31967,
37261: 32207,
37262: 32156,
37263: 32865,
37264: 33609,
37265: 33624,
37266: 33900,
37267: 33980,
37268: 34299,
37269: 35013,
37270: 36208,
37271: 36865,
37272: 36973,
37273: 37783,
37274: 38684,
37275: 39442,
37276: 20687,
37277: 22679,
37278: 24974,
37279: 33235,
37280: 34101,
37281: 36104,
37282: 36896,
37283: 20419,
37284: 20596,
37285: 21063,
37286: 21363,
37287: 24687,
37288: 25417,
37289: 26463,
37290: 28204,
37291: 36275,
37292: 36895,
37293: 20439,
37294: 23646,
37295: 36042,
37296: 26063,
37297: 32154,
37298: 21330,
37299: 34966,
37300: 20854,
37301: 25539,
37302: 23384,
37303: 23403,
37304: 23562,
37305: 25613,
37306: 26449,
37307: 36956,
37308: 20182,
37309: 22810,
37310: 22826,
37311: 27760,
37312: 35409,
37313: 21822,
37314: 22549,
37315: 22949,
37316: 24816,
37317: 25171,
37318: 26561,
37319: 33333,
37320: 26965,
37321: 38464,
37322: 39364,
37323: 39464,
37324: 20307,
37325: 22534,
37326: 23550,
37327: 32784,
37328: 23729,
37329: 24111,
37330: 24453,
37331: 24608,
37332: 24907,
37333: 25140,
37334: 26367,
37335: 27888,
37336: 28382,
37337: 32974,
37338: 33151,
37339: 33492,
37340: 34955,
37341: 36024,
37342: 36864,
37343: 36910,
37344: 38538,
37345: 40667,
37346: 39899,
37347: 20195,
37348: 21488,
37349: 22823,
37350: 31532,
37351: 37261,
37352: 38988,
37353: 40441,
37354: 28381,
37355: 28711,
37356: 21331,
37357: 21828,
37358: 23429,
37359: 25176,
37360: 25246,
37361: 25299,
37362: 27810,
37363: 28655,
37364: 29730,
37365: 35351,
37366: 37944,
37367: 28609,
37368: 35582,
37369: 33592,
37370: 20967,
37371: 34552,
37372: 21482,
37440: 21481,
37441: 20294,
37442: 36948,
37443: 36784,
37444: 22890,
37445: 33073,
37446: 24061,
37447: 31466,
37448: 36799,
37449: 26842,
37450: 35895,
37451: 29432,
37452: 40008,
37453: 27197,
37454: 35504,
37455: 20025,
37456: 21336,
37457: 22022,
37458: 22374,
37459: 25285,
37460: 25506,
37461: 26086,
37462: 27470,
37463: 28129,
37464: 28251,
37465: 28845,
37466: 30701,
37467: 31471,
37468: 31658,
37469: 32187,
37470: 32829,
37471: 32966,
37472: 34507,
37473: 35477,
37474: 37723,
37475: 22243,
37476: 22727,
37477: 24382,
37478: 26029,
37479: 26262,
37480: 27264,
37481: 27573,
37482: 30007,
37483: 35527,
37484: 20516,
37485: 30693,
37486: 22320,
37487: 24347,
37488: 24677,
37489: 26234,
37490: 27744,
37491: 30196,
37492: 31258,
37493: 32622,
37494: 33268,
37495: 34584,
37496: 36933,
37497: 39347,
37498: 31689,
37499: 30044,
37500: 31481,
37501: 31569,
37502: 33988,
37504: 36880,
37505: 31209,
37506: 31378,
37507: 33590,
37508: 23265,
37509: 30528,
37510: 20013,
37511: 20210,
37512: 23449,
37513: 24544,
37514: 25277,
37515: 26172,
37516: 26609,
37517: 27880,
37518: 34411,
37519: 34935,
37520: 35387,
37521: 37198,
37522: 37619,
37523: 39376,
37524: 27159,
37525: 28710,
37526: 29482,
37527: 33511,
37528: 33879,
37529: 36015,
37530: 19969,
37531: 20806,
37532: 20939,
37533: 21899,
37534: 23541,
37535: 24086,
37536: 24115,
37537: 24193,
37538: 24340,
37539: 24373,
37540: 24427,
37541: 24500,
37542: 25074,
37543: 25361,
37544: 26274,
37545: 26397,
37546: 28526,
37547: 29266,
37548: 30010,
37549: 30522,
37550: 32884,
37551: 33081,
37552: 33144,
37553: 34678,
37554: 35519,
37555: 35548,
37556: 36229,
37557: 36339,
37558: 37530,
37559: 38263,
37560: 38914,
37561: 40165,
37562: 21189,
37563: 25431,
37564: 30452,
37565: 26389,
37566: 27784,
37567: 29645,
37568: 36035,
37569: 37806,
37570: 38515,
37571: 27941,
37572: 22684,
37573: 26894,
37574: 27084,
37575: 36861,
37576: 37786,
37577: 30171,
37578: 36890,
37579: 22618,
37580: 26626,
37581: 25524,
37582: 27131,
37583: 20291,
37584: 28460,
37585: 26584,
37586: 36795,
37587: 34086,
37588: 32180,
37589: 37716,
37590: 26943,
37591: 28528,
37592: 22378,
37593: 22775,
37594: 23340,
37595: 32044,
37596: 29226,
37597: 21514,
37598: 37347,
37599: 40372,
37600: 20141,
37601: 20302,
37602: 20572,
37603: 20597,
37604: 21059,
37605: 35998,
37606: 21576,
37607: 22564,
37608: 23450,
37609: 24093,
37610: 24213,
37611: 24237,
37612: 24311,
37613: 24351,
37614: 24716,
37615: 25269,
37616: 25402,
37617: 25552,
37618: 26799,
37619: 27712,
37620: 30855,
37621: 31118,
37622: 31243,
37623: 32224,
37624: 33351,
37625: 35330,
37626: 35558,
37627: 36420,
37628: 36883,
37696: 37048,
37697: 37165,
37698: 37336,
37699: 40718,
37700: 27877,
37701: 25688,
37702: 25826,
37703: 25973,
37704: 28404,
37705: 30340,
37706: 31515,
37707: 36969,
37708: 37841,
37709: 28346,
37710: 21746,
37711: 24505,
37712: 25764,
37713: 36685,
37714: 36845,
37715: 37444,
37716: 20856,
37717: 22635,
37718: 22825,
37719: 23637,
37720: 24215,
37721: 28155,
37722: 32399,
37723: 29980,
37724: 36028,
37725: 36578,
37726: 39003,
37727: 28857,
37728: 20253,
37729: 27583,
37730: 28593,
37731: 3e4,
37732: 38651,
37733: 20814,
37734: 21520,
37735: 22581,
37736: 22615,
37737: 22956,
37738: 23648,
37739: 24466,
37740: 26007,
37741: 26460,
37742: 28193,
37743: 30331,
37744: 33759,
37745: 36077,
37746: 36884,
37747: 37117,
37748: 37709,
37749: 30757,
37750: 30778,
37751: 21162,
37752: 24230,
37753: 22303,
37754: 22900,
37755: 24594,
37756: 20498,
37757: 20826,
37758: 20908,
37760: 20941,
37761: 20992,
37762: 21776,
37763: 22612,
37764: 22616,
37765: 22871,
37766: 23445,
37767: 23798,
37768: 23947,
37769: 24764,
37770: 25237,
37771: 25645,
37772: 26481,
37773: 26691,
37774: 26812,
37775: 26847,
37776: 30423,
37777: 28120,
37778: 28271,
37779: 28059,
37780: 28783,
37781: 29128,
37782: 24403,
37783: 30168,
37784: 31095,
37785: 31561,
37786: 31572,
37787: 31570,
37788: 31958,
37789: 32113,
37790: 21040,
37791: 33891,
37792: 34153,
37793: 34276,
37794: 35342,
37795: 35588,
37796: 35910,
37797: 36367,
37798: 36867,
37799: 36879,
37800: 37913,
37801: 38518,
37802: 38957,
37803: 39472,
37804: 38360,
37805: 20685,
37806: 21205,
37807: 21516,
37808: 22530,
37809: 23566,
37810: 24999,
37811: 25758,
37812: 27934,
37813: 30643,
37814: 31461,
37815: 33012,
37816: 33796,
37817: 36947,
37818: 37509,
37819: 23776,
37820: 40199,
37821: 21311,
37822: 24471,
37823: 24499,
37824: 28060,
37825: 29305,
37826: 30563,
37827: 31167,
37828: 31716,
37829: 27602,
37830: 29420,
37831: 35501,
37832: 26627,
37833: 27233,
37834: 20984,
37835: 31361,
37836: 26932,
37837: 23626,
37838: 40182,
37839: 33515,
37840: 23493,
37841: 37193,
37842: 28702,
37843: 22136,
37844: 23663,
37845: 24775,
37846: 25958,
37847: 27788,
37848: 35930,
37849: 36929,
37850: 38931,
37851: 21585,
37852: 26311,
37853: 37389,
37854: 22856,
37855: 37027,
37856: 20869,
37857: 20045,
37858: 20970,
37859: 34201,
37860: 35598,
37861: 28760,
37862: 25466,
37863: 37707,
37864: 26978,
37865: 39348,
37866: 32260,
37867: 30071,
37868: 21335,
37869: 26976,
37870: 36575,
37871: 38627,
37872: 27741,
37873: 20108,
37874: 23612,
37875: 24336,
37876: 36841,
37877: 21250,
37878: 36049,
37879: 32905,
37880: 34425,
37881: 24319,
37882: 26085,
37883: 20083,
37884: 20837,
37952: 22914,
37953: 23615,
37954: 38894,
37955: 20219,
37956: 22922,
37957: 24525,
37958: 35469,
37959: 28641,
37960: 31152,
37961: 31074,
37962: 23527,
37963: 33905,
37964: 29483,
37965: 29105,
37966: 24180,
37967: 24565,
37968: 25467,
37969: 25754,
37970: 29123,
37971: 31896,
37972: 20035,
37973: 24316,
37974: 20043,
37975: 22492,
37976: 22178,
37977: 24745,
37978: 28611,
37979: 32013,
37980: 33021,
37981: 33075,
37982: 33215,
37983: 36786,
37984: 35223,
37985: 34468,
37986: 24052,
37987: 25226,
37988: 25773,
37989: 35207,
37990: 26487,
37991: 27874,
37992: 27966,
37993: 29750,
37994: 30772,
37995: 23110,
37996: 32629,
37997: 33453,
37998: 39340,
37999: 20467,
38e3: 24259,
38001: 25309,
38002: 25490,
38003: 25943,
38004: 26479,
38005: 30403,
38006: 29260,
38007: 32972,
38008: 32954,
38009: 36649,
38010: 37197,
38011: 20493,
38012: 22521,
38013: 23186,
38014: 26757,
38016: 26995,
38017: 29028,
38018: 29437,
38019: 36023,
38020: 22770,
38021: 36064,
38022: 38506,
38023: 36889,
38024: 34687,
38025: 31204,
38026: 30695,
38027: 33833,
38028: 20271,
38029: 21093,
38030: 21338,
38031: 25293,
38032: 26575,
38033: 27850,
38034: 30333,
38035: 31636,
38036: 31893,
38037: 33334,
38038: 34180,
38039: 36843,
38040: 26333,
38041: 28448,
38042: 29190,
38043: 32283,
38044: 33707,
38045: 39361,
38046: 40614,
38047: 20989,
38048: 31665,
38049: 30834,
38050: 31672,
38051: 32903,
38052: 31560,
38053: 27368,
38054: 24161,
38055: 32908,
38056: 30033,
38057: 30048,
38058: 20843,
38059: 37474,
38060: 28300,
38061: 30330,
38062: 37271,
38063: 39658,
38064: 20240,
38065: 32624,
38066: 25244,
38067: 31567,
38068: 38309,
38069: 40169,
38070: 22138,
38071: 22617,
38072: 34532,
38073: 38588,
38074: 20276,
38075: 21028,
38076: 21322,
38077: 21453,
38078: 21467,
38079: 24070,
38080: 25644,
38081: 26001,
38082: 26495,
38083: 27710,
38084: 27726,
38085: 29256,
38086: 29359,
38087: 29677,
38088: 30036,
38089: 32321,
38090: 33324,
38091: 34281,
38092: 36009,
38093: 31684,
38094: 37318,
38095: 29033,
38096: 38930,
38097: 39151,
38098: 25405,
38099: 26217,
38100: 30058,
38101: 30436,
38102: 30928,
38103: 34115,
38104: 34542,
38105: 21290,
38106: 21329,
38107: 21542,
38108: 22915,
38109: 24199,
38110: 24444,
38111: 24754,
38112: 25161,
38113: 25209,
38114: 25259,
38115: 26e3,
38116: 27604,
38117: 27852,
38118: 30130,
38119: 30382,
38120: 30865,
38121: 31192,
38122: 32203,
38123: 32631,
38124: 32933,
38125: 34987,
38126: 35513,
38127: 36027,
38128: 36991,
38129: 38750,
38130: 39131,
38131: 27147,
38132: 31800,
38133: 20633,
38134: 23614,
38135: 24494,
38136: 26503,
38137: 27608,
38138: 29749,
38139: 30473,
38140: 32654,
38208: 40763,
38209: 26570,
38210: 31255,
38211: 21305,
38212: 30091,
38213: 39661,
38214: 24422,
38215: 33181,
38216: 33777,
38217: 32920,
38218: 24380,
38219: 24517,
38220: 30050,
38221: 31558,
38222: 36924,
38223: 26727,
38224: 23019,
38225: 23195,
38226: 32016,
38227: 30334,
38228: 35628,
38229: 20469,
38230: 24426,
38231: 27161,
38232: 27703,
38233: 28418,
38234: 29922,
38235: 31080,
38236: 34920,
38237: 35413,
38238: 35961,
38239: 24287,
38240: 25551,
38241: 30149,
38242: 31186,
38243: 33495,
38244: 37672,
38245: 37618,
38246: 33948,
38247: 34541,
38248: 39981,
38249: 21697,
38250: 24428,
38251: 25996,
38252: 27996,
38253: 28693,
38254: 36007,
38255: 36051,
38256: 38971,
38257: 25935,
38258: 29942,
38259: 19981,
38260: 20184,
38261: 22496,
38262: 22827,
38263: 23142,
38264: 23500,
38265: 20904,
38266: 24067,
38267: 24220,
38268: 24598,
38269: 25206,
38270: 25975,
38272: 26023,
38273: 26222,
38274: 28014,
38275: 29238,
38276: 31526,
38277: 33104,
38278: 33178,
38279: 33433,
38280: 35676,
38281: 36e3,
38282: 36070,
38283: 36212,
38284: 38428,
38285: 38468,
38286: 20398,
38287: 25771,
38288: 27494,
38289: 33310,
38290: 33889,
38291: 34154,
38292: 37096,
38293: 23553,
38294: 26963,
38295: 39080,
38296: 33914,
38297: 34135,
38298: 20239,
38299: 21103,
38300: 24489,
38301: 24133,
38302: 26381,
38303: 31119,
38304: 33145,
38305: 35079,
38306: 35206,
38307: 28149,
38308: 24343,
38309: 25173,
38310: 27832,
38311: 20175,
38312: 29289,
38313: 39826,
38314: 20998,
38315: 21563,
38316: 22132,
38317: 22707,
38318: 24996,
38319: 25198,
38320: 28954,
38321: 22894,
38322: 31881,
38323: 31966,
38324: 32027,
38325: 38640,
38326: 25991,
38327: 32862,
38328: 19993,
38329: 20341,
38330: 20853,
38331: 22592,
38332: 24163,
38333: 24179,
38334: 24330,
38335: 26564,
38336: 20006,
38337: 34109,
38338: 38281,
38339: 38491,
38340: 31859,
38341: 38913,
38342: 20731,
38343: 22721,
38344: 30294,
38345: 30887,
38346: 21029,
38347: 30629,
38348: 34065,
38349: 31622,
38350: 20559,
38351: 22793,
38352: 29255,
38353: 31687,
38354: 32232,
38355: 36794,
38356: 36820,
38357: 36941,
38358: 20415,
38359: 21193,
38360: 23081,
38361: 24321,
38362: 38829,
38363: 20445,
38364: 33303,
38365: 37610,
38366: 22275,
38367: 25429,
38368: 27497,
38369: 29995,
38370: 35036,
38371: 36628,
38372: 31298,
38373: 21215,
38374: 22675,
38375: 24917,
38376: 25098,
38377: 26286,
38378: 27597,
38379: 31807,
38380: 33769,
38381: 20515,
38382: 20472,
38383: 21253,
38384: 21574,
38385: 22577,
38386: 22857,
38387: 23453,
38388: 23792,
38389: 23791,
38390: 23849,
38391: 24214,
38392: 25265,
38393: 25447,
38394: 25918,
38395: 26041,
38396: 26379,
38464: 27861,
38465: 27873,
38466: 28921,
38467: 30770,
38468: 32299,
38469: 32990,
38470: 33459,
38471: 33804,
38472: 34028,
38473: 34562,
38474: 35090,
38475: 35370,
38476: 35914,
38477: 37030,
38478: 37586,
38479: 39165,
38480: 40179,
38481: 40300,
38482: 20047,
38483: 20129,
38484: 20621,
38485: 21078,
38486: 22346,
38487: 22952,
38488: 24125,
38489: 24536,
38490: 24537,
38491: 25151,
38492: 26292,
38493: 26395,
38494: 26576,
38495: 26834,
38496: 20882,
38497: 32033,
38498: 32938,
38499: 33192,
38500: 35584,
38501: 35980,
38502: 36031,
38503: 37502,
38504: 38450,
38505: 21536,
38506: 38956,
38507: 21271,
38508: 20693,
38509: 21340,
38510: 22696,
38511: 25778,
38512: 26420,
38513: 29287,
38514: 30566,
38515: 31302,
38516: 37350,
38517: 21187,
38518: 27809,
38519: 27526,
38520: 22528,
38521: 24140,
38522: 22868,
38523: 26412,
38524: 32763,
38525: 20961,
38526: 30406,
38528: 25705,
38529: 30952,
38530: 39764,
38531: 40635,
38532: 22475,
38533: 22969,
38534: 26151,
38535: 26522,
38536: 27598,
38537: 21737,
38538: 27097,
38539: 24149,
38540: 33180,
38541: 26517,
38542: 39850,
38543: 26622,
38544: 40018,
38545: 26717,
38546: 20134,
38547: 20451,
38548: 21448,
38549: 25273,
38550: 26411,
38551: 27819,
38552: 36804,
38553: 20397,
38554: 32365,
38555: 40639,
38556: 19975,
38557: 24930,
38558: 28288,
38559: 28459,
38560: 34067,
38561: 21619,
38562: 26410,
38563: 39749,
38564: 24051,
38565: 31637,
38566: 23724,
38567: 23494,
38568: 34588,
38569: 28234,
38570: 34001,
38571: 31252,
38572: 33032,
38573: 22937,
38574: 31885,
38575: 27665,
38576: 30496,
38577: 21209,
38578: 22818,
38579: 28961,
38580: 29279,
38581: 30683,
38582: 38695,
38583: 40289,
38584: 26891,
38585: 23167,
38586: 23064,
38587: 20901,
38588: 21517,
38589: 21629,
38590: 26126,
38591: 30431,
38592: 36855,
38593: 37528,
38594: 40180,
38595: 23018,
38596: 29277,
38597: 28357,
38598: 20813,
38599: 26825,
38600: 32191,
38601: 32236,
38602: 38754,
38603: 40634,
38604: 25720,
38605: 27169,
38606: 33538,
38607: 22916,
38608: 23391,
38609: 27611,
38610: 29467,
38611: 30450,
38612: 32178,
38613: 32791,
38614: 33945,
38615: 20786,
38616: 26408,
38617: 40665,
38618: 30446,
38619: 26466,
38620: 21247,
38621: 39173,
38622: 23588,
38623: 25147,
38624: 31870,
38625: 36016,
38626: 21839,
38627: 24758,
38628: 32011,
38629: 38272,
38630: 21249,
38631: 20063,
38632: 20918,
38633: 22812,
38634: 29242,
38635: 32822,
38636: 37326,
38637: 24357,
38638: 30690,
38639: 21380,
38640: 24441,
38641: 32004,
38642: 34220,
38643: 35379,
38644: 36493,
38645: 38742,
38646: 26611,
38647: 34222,
38648: 37971,
38649: 24841,
38650: 24840,
38651: 27833,
38652: 30290,
38720: 35565,
38721: 36664,
38722: 21807,
38723: 20305,
38724: 20778,
38725: 21191,
38726: 21451,
38727: 23461,
38728: 24189,
38729: 24736,
38730: 24962,
38731: 25558,
38732: 26377,
38733: 26586,
38734: 28263,
38735: 28044,
38736: 29494,
38737: 29495,
38738: 30001,
38739: 31056,
38740: 35029,
38741: 35480,
38742: 36938,
38743: 37009,
38744: 37109,
38745: 38596,
38746: 34701,
38747: 22805,
38748: 20104,
38749: 20313,
38750: 19982,
38751: 35465,
38752: 36671,
38753: 38928,
38754: 20653,
38755: 24188,
38756: 22934,
38757: 23481,
38758: 24248,
38759: 25562,
38760: 25594,
38761: 25793,
38762: 26332,
38763: 26954,
38764: 27096,
38765: 27915,
38766: 28342,
38767: 29076,
38768: 29992,
38769: 31407,
38770: 32650,
38771: 32768,
38772: 33865,
38773: 33993,
38774: 35201,
38775: 35617,
38776: 36362,
38777: 36965,
38778: 38525,
38779: 39178,
38780: 24958,
38781: 25233,
38782: 27442,
38784: 27779,
38785: 28020,
38786: 32716,
38787: 32764,
38788: 28096,
38789: 32645,
38790: 34746,
38791: 35064,
38792: 26469,
38793: 33713,
38794: 38972,
38795: 38647,
38796: 27931,
38797: 32097,
38798: 33853,
38799: 37226,
38800: 20081,
38801: 21365,
38802: 23888,
38803: 27396,
38804: 28651,
38805: 34253,
38806: 34349,
38807: 35239,
38808: 21033,
38809: 21519,
38810: 23653,
38811: 26446,
38812: 26792,
38813: 29702,
38814: 29827,
38815: 30178,
38816: 35023,
38817: 35041,
38818: 37324,
38819: 38626,
38820: 38520,
38821: 24459,
38822: 29575,
38823: 31435,
38824: 33870,
38825: 25504,
38826: 30053,
38827: 21129,
38828: 27969,
38829: 28316,
38830: 29705,
38831: 30041,
38832: 30827,
38833: 31890,
38834: 38534,
38835: 31452,
38836: 40845,
38837: 20406,
38838: 24942,
38839: 26053,
38840: 34396,
38841: 20102,
38842: 20142,
38843: 20698,
38844: 20001,
38845: 20940,
38846: 23534,
38847: 26009,
38848: 26753,
38849: 28092,
38850: 29471,
38851: 30274,
38852: 30637,
38853: 31260,
38854: 31975,
38855: 33391,
38856: 35538,
38857: 36988,
38858: 37327,
38859: 38517,
38860: 38936,
38861: 21147,
38862: 32209,
38863: 20523,
38864: 21400,
38865: 26519,
38866: 28107,
38867: 29136,
38868: 29747,
38869: 33256,
38870: 36650,
38871: 38563,
38872: 40023,
38873: 40607,
38874: 29792,
38875: 22593,
38876: 28057,
38877: 32047,
38878: 39006,
38879: 20196,
38880: 20278,
38881: 20363,
38882: 20919,
38883: 21169,
38884: 23994,
38885: 24604,
38886: 29618,
38887: 31036,
38888: 33491,
38889: 37428,
38890: 38583,
38891: 38646,
38892: 38666,
38893: 40599,
38894: 40802,
38895: 26278,
38896: 27508,
38897: 21015,
38898: 21155,
38899: 28872,
38900: 35010,
38901: 24265,
38902: 24651,
38903: 24976,
38904: 28451,
38905: 29001,
38906: 31806,
38907: 32244,
38908: 32879,
38976: 34030,
38977: 36899,
38978: 37676,
38979: 21570,
38980: 39791,
38981: 27347,
38982: 28809,
38983: 36034,
38984: 36335,
38985: 38706,
38986: 21172,
38987: 23105,
38988: 24266,
38989: 24324,
38990: 26391,
38991: 27004,
38992: 27028,
38993: 28010,
38994: 28431,
38995: 29282,
38996: 29436,
38997: 31725,
38998: 32769,
38999: 32894,
39e3: 34635,
39001: 37070,
39002: 20845,
39003: 40595,
39004: 31108,
39005: 32907,
39006: 37682,
39007: 35542,
39008: 20525,
39009: 21644,
39010: 35441,
39011: 27498,
39012: 36036,
39013: 33031,
39014: 24785,
39015: 26528,
39016: 40434,
39017: 20121,
39018: 20120,
39019: 39952,
39020: 35435,
39021: 34241,
39022: 34152,
39023: 26880,
39024: 28286,
39025: 30871,
39026: 33109,
39071: 24332,
39072: 19984,
39073: 19989,
39074: 20010,
39075: 20017,
39076: 20022,
39077: 20028,
39078: 20031,
39079: 20034,
39080: 20054,
39081: 20056,
39082: 20098,
39083: 20101,
39084: 35947,
39085: 20106,
39086: 33298,
39087: 24333,
39088: 20110,
39089: 20126,
39090: 20127,
39091: 20128,
39092: 20130,
39093: 20144,
39094: 20147,
39095: 20150,
39096: 20174,
39097: 20173,
39098: 20164,
39099: 20166,
39100: 20162,
39101: 20183,
39102: 20190,
39103: 20205,
39104: 20191,
39105: 20215,
39106: 20233,
39107: 20314,
39108: 20272,
39109: 20315,
39110: 20317,
39111: 20311,
39112: 20295,
39113: 20342,
39114: 20360,
39115: 20367,
39116: 20376,
39117: 20347,
39118: 20329,
39119: 20336,
39120: 20369,
39121: 20335,
39122: 20358,
39123: 20374,
39124: 20760,
39125: 20436,
39126: 20447,
39127: 20430,
39128: 20440,
39129: 20443,
39130: 20433,
39131: 20442,
39132: 20432,
39133: 20452,
39134: 20453,
39135: 20506,
39136: 20520,
39137: 20500,
39138: 20522,
39139: 20517,
39140: 20485,
39141: 20252,
39142: 20470,
39143: 20513,
39144: 20521,
39145: 20524,
39146: 20478,
39147: 20463,
39148: 20497,
39149: 20486,
39150: 20547,
39151: 20551,
39152: 26371,
39153: 20565,
39154: 20560,
39155: 20552,
39156: 20570,
39157: 20566,
39158: 20588,
39159: 20600,
39160: 20608,
39161: 20634,
39162: 20613,
39163: 20660,
39164: 20658,
39232: 20681,
39233: 20682,
39234: 20659,
39235: 20674,
39236: 20694,
39237: 20702,
39238: 20709,
39239: 20717,
39240: 20707,
39241: 20718,
39242: 20729,
39243: 20725,
39244: 20745,
39245: 20737,
39246: 20738,
39247: 20758,
39248: 20757,
39249: 20756,
39250: 20762,
39251: 20769,
39252: 20794,
39253: 20791,
39254: 20796,
39255: 20795,
39256: 20799,
39257: 20800,
39258: 20818,
39259: 20812,
39260: 20820,
39261: 20834,
39262: 31480,
39263: 20841,
39264: 20842,
39265: 20846,
39266: 20864,
39267: 20866,
39268: 22232,
39269: 20876,
39270: 20873,
39271: 20879,
39272: 20881,
39273: 20883,
39274: 20885,
39275: 20886,
39276: 20900,
39277: 20902,
39278: 20898,
39279: 20905,
39280: 20906,
39281: 20907,
39282: 20915,
39283: 20913,
39284: 20914,
39285: 20912,
39286: 20917,
39287: 20925,
39288: 20933,
39289: 20937,
39290: 20955,
39291: 20960,
39292: 34389,
39293: 20969,
39294: 20973,
39296: 20976,
39297: 20981,
39298: 20990,
39299: 20996,
39300: 21003,
39301: 21012,
39302: 21006,
39303: 21031,
39304: 21034,
39305: 21038,
39306: 21043,
39307: 21049,
39308: 21071,
39309: 21060,
39310: 21067,
39311: 21068,
39312: 21086,
39313: 21076,
39314: 21098,
39315: 21108,
39316: 21097,
39317: 21107,
39318: 21119,
39319: 21117,
39320: 21133,
39321: 21140,
39322: 21138,
39323: 21105,
39324: 21128,
39325: 21137,
39326: 36776,
39327: 36775,
39328: 21164,
39329: 21165,
39330: 21180,
39331: 21173,
39332: 21185,
39333: 21197,
39334: 21207,
39335: 21214,
39336: 21219,
39337: 21222,
39338: 39149,
39339: 21216,
39340: 21235,
39341: 21237,
39342: 21240,
39343: 21241,
39344: 21254,
39345: 21256,
39346: 30008,
39347: 21261,
39348: 21264,
39349: 21263,
39350: 21269,
39351: 21274,
39352: 21283,
39353: 21295,
39354: 21297,
39355: 21299,
39356: 21304,
39357: 21312,
39358: 21318,
39359: 21317,
39360: 19991,
39361: 21321,
39362: 21325,
39363: 20950,
39364: 21342,
39365: 21353,
39366: 21358,
39367: 22808,
39368: 21371,
39369: 21367,
39370: 21378,
39371: 21398,
39372: 21408,
39373: 21414,
39374: 21413,
39375: 21422,
39376: 21424,
39377: 21430,
39378: 21443,
39379: 31762,
39380: 38617,
39381: 21471,
39382: 26364,
39383: 29166,
39384: 21486,
39385: 21480,
39386: 21485,
39387: 21498,
39388: 21505,
39389: 21565,
39390: 21568,
39391: 21548,
39392: 21549,
39393: 21564,
39394: 21550,
39395: 21558,
39396: 21545,
39397: 21533,
39398: 21582,
39399: 21647,
39400: 21621,
39401: 21646,
39402: 21599,
39403: 21617,
39404: 21623,
39405: 21616,
39406: 21650,
39407: 21627,
39408: 21632,
39409: 21622,
39410: 21636,
39411: 21648,
39412: 21638,
39413: 21703,
39414: 21666,
39415: 21688,
39416: 21669,
39417: 21676,
39418: 21700,
39419: 21704,
39420: 21672,
39488: 21675,
39489: 21698,
39490: 21668,
39491: 21694,
39492: 21692,
39493: 21720,
39494: 21733,
39495: 21734,
39496: 21775,
39497: 21780,
39498: 21757,
39499: 21742,
39500: 21741,
39501: 21754,
39502: 21730,
39503: 21817,
39504: 21824,
39505: 21859,
39506: 21836,
39507: 21806,
39508: 21852,
39509: 21829,
39510: 21846,
39511: 21847,
39512: 21816,
39513: 21811,
39514: 21853,
39515: 21913,
39516: 21888,
39517: 21679,
39518: 21898,
39519: 21919,
39520: 21883,
39521: 21886,
39522: 21912,
39523: 21918,
39524: 21934,
39525: 21884,
39526: 21891,
39527: 21929,
39528: 21895,
39529: 21928,
39530: 21978,
39531: 21957,
39532: 21983,
39533: 21956,
39534: 21980,
39535: 21988,
39536: 21972,
39537: 22036,
39538: 22007,
39539: 22038,
39540: 22014,
39541: 22013,
39542: 22043,
39543: 22009,
39544: 22094,
39545: 22096,
39546: 29151,
39547: 22068,
39548: 22070,
39549: 22066,
39550: 22072,
39552: 22123,
39553: 22116,
39554: 22063,
39555: 22124,
39556: 22122,
39557: 22150,
39558: 22144,
39559: 22154,
39560: 22176,
39561: 22164,
39562: 22159,
39563: 22181,
39564: 22190,
39565: 22198,
39566: 22196,
39567: 22210,
39568: 22204,
39569: 22209,
39570: 22211,
39571: 22208,
39572: 22216,
39573: 22222,
39574: 22225,
39575: 22227,
39576: 22231,
39577: 22254,
39578: 22265,
39579: 22272,
39580: 22271,
39581: 22276,
39582: 22281,
39583: 22280,
39584: 22283,
39585: 22285,
39586: 22291,
39587: 22296,
39588: 22294,
39589: 21959,
39590: 22300,
39591: 22310,
39592: 22327,
39593: 22328,
39594: 22350,
39595: 22331,
39596: 22336,
39597: 22351,
39598: 22377,
39599: 22464,
39600: 22408,
39601: 22369,
39602: 22399,
39603: 22409,
39604: 22419,
39605: 22432,
39606: 22451,
39607: 22436,
39608: 22442,
39609: 22448,
39610: 22467,
39611: 22470,
39612: 22484,
39613: 22482,
39614: 22483,
39615: 22538,
39616: 22486,
39617: 22499,
39618: 22539,
39619: 22553,
39620: 22557,
39621: 22642,
39622: 22561,
39623: 22626,
39624: 22603,
39625: 22640,
39626: 27584,
39627: 22610,
39628: 22589,
39629: 22649,
39630: 22661,
39631: 22713,
39632: 22687,
39633: 22699,
39634: 22714,
39635: 22750,
39636: 22715,
39637: 22712,
39638: 22702,
39639: 22725,
39640: 22739,
39641: 22737,
39642: 22743,
39643: 22745,
39644: 22744,
39645: 22757,
39646: 22748,
39647: 22756,
39648: 22751,
39649: 22767,
39650: 22778,
39651: 22777,
39652: 22779,
39653: 22780,
39654: 22781,
39655: 22786,
39656: 22794,
39657: 22800,
39658: 22811,
39659: 26790,
39660: 22821,
39661: 22828,
39662: 22829,
39663: 22834,
39664: 22840,
39665: 22846,
39666: 31442,
39667: 22869,
39668: 22864,
39669: 22862,
39670: 22874,
39671: 22872,
39672: 22882,
39673: 22880,
39674: 22887,
39675: 22892,
39676: 22889,
39744: 22904,
39745: 22913,
39746: 22941,
39747: 20318,
39748: 20395,
39749: 22947,
39750: 22962,
39751: 22982,
39752: 23016,
39753: 23004,
39754: 22925,
39755: 23001,
39756: 23002,
39757: 23077,
39758: 23071,
39759: 23057,
39760: 23068,
39761: 23049,
39762: 23066,
39763: 23104,
39764: 23148,
39765: 23113,
39766: 23093,
39767: 23094,
39768: 23138,
39769: 23146,
39770: 23194,
39771: 23228,
39772: 23230,
39773: 23243,
39774: 23234,
39775: 23229,
39776: 23267,
39777: 23255,
39778: 23270,
39779: 23273,
39780: 23254,
39781: 23290,
39782: 23291,
39783: 23308,
39784: 23307,
39785: 23318,
39786: 23346,
39787: 23248,
39788: 23338,
39789: 23350,
39790: 23358,
39791: 23363,
39792: 23365,
39793: 23360,
39794: 23377,
39795: 23381,
39796: 23386,
39797: 23387,
39798: 23397,
39799: 23401,
39800: 23408,
39801: 23411,
39802: 23413,
39803: 23416,
39804: 25992,
39805: 23418,
39806: 23424,
39808: 23427,
39809: 23462,
39810: 23480,
39811: 23491,
39812: 23495,
39813: 23497,
39814: 23508,
39815: 23504,
39816: 23524,
39817: 23526,
39818: 23522,
39819: 23518,
39820: 23525,
39821: 23531,
39822: 23536,
39823: 23542,
39824: 23539,
39825: 23557,
39826: 23559,
39827: 23560,
39828: 23565,
39829: 23571,
39830: 23584,
39831: 23586,
39832: 23592,
39833: 23608,
39834: 23609,
39835: 23617,
39836: 23622,
39837: 23630,
39838: 23635,
39839: 23632,
39840: 23631,
39841: 23409,
39842: 23660,
39843: 23662,
39844: 20066,
39845: 23670,
39846: 23673,
39847: 23692,
39848: 23697,
39849: 23700,
39850: 22939,
39851: 23723,
39852: 23739,
39853: 23734,
39854: 23740,
39855: 23735,
39856: 23749,
39857: 23742,
39858: 23751,
39859: 23769,
39860: 23785,
39861: 23805,
39862: 23802,
39863: 23789,
39864: 23948,
39865: 23786,
39866: 23819,
39867: 23829,
39868: 23831,
39869: 23900,
39870: 23839,
39871: 23835,
39872: 23825,
39873: 23828,
39874: 23842,
39875: 23834,
39876: 23833,
39877: 23832,
39878: 23884,
39879: 23890,
39880: 23886,
39881: 23883,
39882: 23916,
39883: 23923,
39884: 23926,
39885: 23943,
39886: 23940,
39887: 23938,
39888: 23970,
39889: 23965,
39890: 23980,
39891: 23982,
39892: 23997,
39893: 23952,
39894: 23991,
39895: 23996,
39896: 24009,
39897: 24013,
39898: 24019,
39899: 24018,
39900: 24022,
39901: 24027,
39902: 24043,
39903: 24050,
39904: 24053,
39905: 24075,
39906: 24090,
39907: 24089,
39908: 24081,
39909: 24091,
39910: 24118,
39911: 24119,
39912: 24132,
39913: 24131,
39914: 24128,
39915: 24142,
39916: 24151,
39917: 24148,
39918: 24159,
39919: 24162,
39920: 24164,
39921: 24135,
39922: 24181,
39923: 24182,
39924: 24186,
39925: 40636,
39926: 24191,
39927: 24224,
39928: 24257,
39929: 24258,
39930: 24264,
39931: 24272,
39932: 24271,
4e4: 24278,
40001: 24291,
40002: 24285,
40003: 24282,
40004: 24283,
40005: 24290,
40006: 24289,
40007: 24296,
40008: 24297,
40009: 24300,
40010: 24305,
40011: 24307,
40012: 24304,
40013: 24308,
40014: 24312,
40015: 24318,
40016: 24323,
40017: 24329,
40018: 24413,
40019: 24412,
40020: 24331,
40021: 24337,
40022: 24342,
40023: 24361,
40024: 24365,
40025: 24376,
40026: 24385,
40027: 24392,
40028: 24396,
40029: 24398,
40030: 24367,
40031: 24401,
40032: 24406,
40033: 24407,
40034: 24409,
40035: 24417,
40036: 24429,
40037: 24435,
40038: 24439,
40039: 24451,
40040: 24450,
40041: 24447,
40042: 24458,
40043: 24456,
40044: 24465,
40045: 24455,
40046: 24478,
40047: 24473,
40048: 24472,
40049: 24480,
40050: 24488,
40051: 24493,
40052: 24508,
40053: 24534,
40054: 24571,
40055: 24548,
40056: 24568,
40057: 24561,
40058: 24541,
40059: 24755,
40060: 24575,
40061: 24609,
40062: 24672,
40064: 24601,
40065: 24592,
40066: 24617,
40067: 24590,
40068: 24625,
40069: 24603,
40070: 24597,
40071: 24619,
40072: 24614,
40073: 24591,
40074: 24634,
40075: 24666,
40076: 24641,
40077: 24682,
40078: 24695,
40079: 24671,
40080: 24650,
40081: 24646,
40082: 24653,
40083: 24675,
40084: 24643,
40085: 24676,
40086: 24642,
40087: 24684,
40088: 24683,
40089: 24665,
40090: 24705,
40091: 24717,
40092: 24807,
40093: 24707,
40094: 24730,
40095: 24708,
40096: 24731,
40097: 24726,
40098: 24727,
40099: 24722,
40100: 24743,
40101: 24715,
40102: 24801,
40103: 24760,
40104: 24800,
40105: 24787,
40106: 24756,
40107: 24560,
40108: 24765,
40109: 24774,
40110: 24757,
40111: 24792,
40112: 24909,
40113: 24853,
40114: 24838,
40115: 24822,
40116: 24823,
40117: 24832,
40118: 24820,
40119: 24826,
40120: 24835,
40121: 24865,
40122: 24827,
40123: 24817,
40124: 24845,
40125: 24846,
40126: 24903,
40127: 24894,
40128: 24872,
40129: 24871,
40130: 24906,
40131: 24895,
40132: 24892,
40133: 24876,
40134: 24884,
40135: 24893,
40136: 24898,
40137: 24900,
40138: 24947,
40139: 24951,
40140: 24920,
40141: 24921,
40142: 24922,
40143: 24939,
40144: 24948,
40145: 24943,
40146: 24933,
40147: 24945,
40148: 24927,
40149: 24925,
40150: 24915,
40151: 24949,
40152: 24985,
40153: 24982,
40154: 24967,
40155: 25004,
40156: 24980,
40157: 24986,
40158: 24970,
40159: 24977,
40160: 25003,
40161: 25006,
40162: 25036,
40163: 25034,
40164: 25033,
40165: 25079,
40166: 25032,
40167: 25027,
40168: 25030,
40169: 25018,
40170: 25035,
40171: 32633,
40172: 25037,
40173: 25062,
40174: 25059,
40175: 25078,
40176: 25082,
40177: 25076,
40178: 25087,
40179: 25085,
40180: 25084,
40181: 25086,
40182: 25088,
40183: 25096,
40184: 25097,
40185: 25101,
40186: 25100,
40187: 25108,
40188: 25115,
40256: 25118,
40257: 25121,
40258: 25130,
40259: 25134,
40260: 25136,
40261: 25138,
40262: 25139,
40263: 25153,
40264: 25166,
40265: 25182,
40266: 25187,
40267: 25179,
40268: 25184,
40269: 25192,
40270: 25212,
40271: 25218,
40272: 25225,
40273: 25214,
40274: 25234,
40275: 25235,
40276: 25238,
40277: 25300,
40278: 25219,
40279: 25236,
40280: 25303,
40281: 25297,
40282: 25275,
40283: 25295,
40284: 25343,
40285: 25286,
40286: 25812,
40287: 25288,
40288: 25308,
40289: 25292,
40290: 25290,
40291: 25282,
40292: 25287,
40293: 25243,
40294: 25289,
40295: 25356,
40296: 25326,
40297: 25329,
40298: 25383,
40299: 25346,
40300: 25352,
40301: 25327,
40302: 25333,
40303: 25424,
40304: 25406,
40305: 25421,
40306: 25628,
40307: 25423,
40308: 25494,
40309: 25486,
40310: 25472,
40311: 25515,
40312: 25462,
40313: 25507,
40314: 25487,
40315: 25481,
40316: 25503,
40317: 25525,
40318: 25451,
40320: 25449,
40321: 25534,
40322: 25577,
40323: 25536,
40324: 25542,
40325: 25571,
40326: 25545,
40327: 25554,
40328: 25590,
40329: 25540,
40330: 25622,
40331: 25652,
40332: 25606,
40333: 25619,
40334: 25638,
40335: 25654,
40336: 25885,
40337: 25623,
40338: 25640,
40339: 25615,
40340: 25703,
40341: 25711,
40342: 25718,
40343: 25678,
40344: 25898,
40345: 25749,
40346: 25747,
40347: 25765,
40348: 25769,
40349: 25736,
40350: 25788,
40351: 25818,
40352: 25810,
40353: 25797,
40354: 25799,
40355: 25787,
40356: 25816,
40357: 25794,
40358: 25841,
40359: 25831,
40360: 33289,
40361: 25824,
40362: 25825,
40363: 25260,
40364: 25827,
40365: 25839,
40366: 25900,
40367: 25846,
40368: 25844,
40369: 25842,
40370: 25850,
40371: 25856,
40372: 25853,
40373: 25880,
40374: 25884,
40375: 25861,
40376: 25892,
40377: 25891,
40378: 25899,
40379: 25908,
40380: 25909,
40381: 25911,
40382: 25910,
40383: 25912,
40384: 30027,
40385: 25928,
40386: 25942,
40387: 25941,
40388: 25933,
40389: 25944,
40390: 25950,
40391: 25949,
40392: 25970,
40393: 25976,
40394: 25986,
40395: 25987,
40396: 35722,
40397: 26011,
40398: 26015,
40399: 26027,
40400: 26039,
40401: 26051,
40402: 26054,
40403: 26049,
40404: 26052,
40405: 26060,
40406: 26066,
40407: 26075,
40408: 26073,
40409: 26080,
40410: 26081,
40411: 26097,
40412: 26482,
40413: 26122,
40414: 26115,
40415: 26107,
40416: 26483,
40417: 26165,
40418: 26166,
40419: 26164,
40420: 26140,
40421: 26191,
40422: 26180,
40423: 26185,
40424: 26177,
40425: 26206,
40426: 26205,
40427: 26212,
40428: 26215,
40429: 26216,
40430: 26207,
40431: 26210,
40432: 26224,
40433: 26243,
40434: 26248,
40435: 26254,
40436: 26249,
40437: 26244,
40438: 26264,
40439: 26269,
40440: 26305,
40441: 26297,
40442: 26313,
40443: 26302,
40444: 26300,
40512: 26308,
40513: 26296,
40514: 26326,
40515: 26330,
40516: 26336,
40517: 26175,
40518: 26342,
40519: 26345,
40520: 26352,
40521: 26357,
40522: 26359,
40523: 26383,
40524: 26390,
40525: 26398,
40526: 26406,
40527: 26407,
40528: 38712,
40529: 26414,
40530: 26431,
40531: 26422,
40532: 26433,
40533: 26424,
40534: 26423,
40535: 26438,
40536: 26462,
40537: 26464,
40538: 26457,
40539: 26467,
40540: 26468,
40541: 26505,
40542: 26480,
40543: 26537,
40544: 26492,
40545: 26474,
40546: 26508,
40547: 26507,
40548: 26534,
40549: 26529,
40550: 26501,
40551: 26551,
40552: 26607,
40553: 26548,
40554: 26604,
40555: 26547,
40556: 26601,
40557: 26552,
40558: 26596,
40559: 26590,
40560: 26589,
40561: 26594,
40562: 26606,
40563: 26553,
40564: 26574,
40565: 26566,
40566: 26599,
40567: 27292,
40568: 26654,
40569: 26694,
40570: 26665,
40571: 26688,
40572: 26701,
40573: 26674,
40574: 26702,
40576: 26803,
40577: 26667,
40578: 26713,
40579: 26723,
40580: 26743,
40581: 26751,
40582: 26783,
40583: 26767,
40584: 26797,
40585: 26772,
40586: 26781,
40587: 26779,
40588: 26755,
40589: 27310,
40590: 26809,
40591: 26740,
40592: 26805,
40593: 26784,
40594: 26810,
40595: 26895,
40596: 26765,
40597: 26750,
40598: 26881,
40599: 26826,
40600: 26888,
40601: 26840,
40602: 26914,
40603: 26918,
40604: 26849,
40605: 26892,
40606: 26829,
40607: 26836,
40608: 26855,
40609: 26837,
40610: 26934,
40611: 26898,
40612: 26884,
40613: 26839,
40614: 26851,
40615: 26917,
40616: 26873,
40617: 26848,
40618: 26863,
40619: 26920,
40620: 26922,
40621: 26906,
40622: 26915,
40623: 26913,
40624: 26822,
40625: 27001,
40626: 26999,
40627: 26972,
40628: 27e3,
40629: 26987,
40630: 26964,
40631: 27006,
40632: 26990,
40633: 26937,
40634: 26996,
40635: 26941,
40636: 26969,
40637: 26928,
40638: 26977,
40639: 26974,
40640: 26973,
40641: 27009,
40642: 26986,
40643: 27058,
40644: 27054,
40645: 27088,
40646: 27071,
40647: 27073,
40648: 27091,
40649: 27070,
40650: 27086,
40651: 23528,
40652: 27082,
40653: 27101,
40654: 27067,
40655: 27075,
40656: 27047,
40657: 27182,
40658: 27025,
40659: 27040,
40660: 27036,
40661: 27029,
40662: 27060,
40663: 27102,
40664: 27112,
40665: 27138,
40666: 27163,
40667: 27135,
40668: 27402,
40669: 27129,
40670: 27122,
40671: 27111,
40672: 27141,
40673: 27057,
40674: 27166,
40675: 27117,
40676: 27156,
40677: 27115,
40678: 27146,
40679: 27154,
40680: 27329,
40681: 27171,
40682: 27155,
40683: 27204,
40684: 27148,
40685: 27250,
40686: 27190,
40687: 27256,
40688: 27207,
40689: 27234,
40690: 27225,
40691: 27238,
40692: 27208,
40693: 27192,
40694: 27170,
40695: 27280,
40696: 27277,
40697: 27296,
40698: 27268,
40699: 27298,
40700: 27299,
40768: 27287,
40769: 34327,
40770: 27323,
40771: 27331,
40772: 27330,
40773: 27320,
40774: 27315,
40775: 27308,
40776: 27358,
40777: 27345,
40778: 27359,
40779: 27306,
40780: 27354,
40781: 27370,
40782: 27387,
40783: 27397,
40784: 34326,
40785: 27386,
40786: 27410,
40787: 27414,
40788: 39729,
40789: 27423,
40790: 27448,
40791: 27447,
40792: 30428,
40793: 27449,
40794: 39150,
40795: 27463,
40796: 27459,
40797: 27465,
40798: 27472,
40799: 27481,
40800: 27476,
40801: 27483,
40802: 27487,
40803: 27489,
40804: 27512,
40805: 27513,
40806: 27519,
40807: 27520,
40808: 27524,
40809: 27523,
40810: 27533,
40811: 27544,
40812: 27541,
40813: 27550,
40814: 27556,
40815: 27562,
40816: 27563,
40817: 27567,
40818: 27570,
40819: 27569,
40820: 27571,
40821: 27575,
40822: 27580,
40823: 27590,
40824: 27595,
40825: 27603,
40826: 27615,
40827: 27628,
40828: 27627,
40829: 27635,
40830: 27631,
40832: 40638,
40833: 27656,
40834: 27667,
40835: 27668,
40836: 27675,
40837: 27684,
40838: 27683,
40839: 27742,
40840: 27733,
40841: 27746,
40842: 27754,
40843: 27778,
40844: 27789,
40845: 27802,
40846: 27777,
40847: 27803,
40848: 27774,
40849: 27752,
40850: 27763,
40851: 27794,
40852: 27792,
40853: 27844,
40854: 27889,
40855: 27859,
40856: 27837,
40857: 27863,
40858: 27845,
40859: 27869,
40860: 27822,
40861: 27825,
40862: 27838,
40863: 27834,
40864: 27867,
40865: 27887,
40866: 27865,
40867: 27882,
40868: 27935,
40869: 34893,
40870: 27958,
40871: 27947,
40872: 27965,
40873: 27960,
40874: 27929,
40875: 27957,
40876: 27955,
40877: 27922,
40878: 27916,
40879: 28003,
40880: 28051,
40881: 28004,
40882: 27994,
40883: 28025,
40884: 27993,
40885: 28046,
40886: 28053,
40887: 28644,
40888: 28037,
40889: 28153,
40890: 28181,
40891: 28170,
40892: 28085,
40893: 28103,
40894: 28134,
40895: 28088,
40896: 28102,
40897: 28140,
40898: 28126,
40899: 28108,
40900: 28136,
40901: 28114,
40902: 28101,
40903: 28154,
40904: 28121,
40905: 28132,
40906: 28117,
40907: 28138,
40908: 28142,
40909: 28205,
40910: 28270,
40911: 28206,
40912: 28185,
40913: 28274,
40914: 28255,
40915: 28222,
40916: 28195,
40917: 28267,
40918: 28203,
40919: 28278,
40920: 28237,
40921: 28191,
40922: 28227,
40923: 28218,
40924: 28238,
40925: 28196,
40926: 28415,
40927: 28189,
40928: 28216,
40929: 28290,
40930: 28330,
40931: 28312,
40932: 28361,
40933: 28343,
40934: 28371,
40935: 28349,
40936: 28335,
40937: 28356,
40938: 28338,
40939: 28372,
40940: 28373,
40941: 28303,
40942: 28325,
40943: 28354,
40944: 28319,
40945: 28481,
40946: 28433,
40947: 28748,
40948: 28396,
40949: 28408,
40950: 28414,
40951: 28479,
40952: 28402,
40953: 28465,
40954: 28399,
40955: 28466,
40956: 28364,
57408: 28478,
57409: 28435,
57410: 28407,
57411: 28550,
57412: 28538,
57413: 28536,
57414: 28545,
57415: 28544,
57416: 28527,
57417: 28507,
57418: 28659,
57419: 28525,
57420: 28546,
57421: 28540,
57422: 28504,
57423: 28558,
57424: 28561,
57425: 28610,
57426: 28518,
57427: 28595,
57428: 28579,
57429: 28577,
57430: 28580,
57431: 28601,
57432: 28614,
57433: 28586,
57434: 28639,
57435: 28629,
57436: 28652,
57437: 28628,
57438: 28632,
57439: 28657,
57440: 28654,
57441: 28635,
57442: 28681,
57443: 28683,
57444: 28666,
57445: 28689,
57446: 28673,
57447: 28687,
57448: 28670,
57449: 28699,
57450: 28698,
57451: 28532,
57452: 28701,
57453: 28696,
57454: 28703,
57455: 28720,
57456: 28734,
57457: 28722,
57458: 28753,
57459: 28771,
57460: 28825,
57461: 28818,
57462: 28847,
57463: 28913,
57464: 28844,
57465: 28856,
57466: 28851,
57467: 28846,
57468: 28895,
57469: 28875,
57470: 28893,
57472: 28889,
57473: 28937,
57474: 28925,
57475: 28956,
57476: 28953,
57477: 29029,
57478: 29013,
57479: 29064,
57480: 29030,
57481: 29026,
57482: 29004,
57483: 29014,
57484: 29036,
57485: 29071,
57486: 29179,
57487: 29060,
57488: 29077,
57489: 29096,
57490: 29100,
57491: 29143,
57492: 29113,
57493: 29118,
57494: 29138,
57495: 29129,
57496: 29140,
57497: 29134,
57498: 29152,
57499: 29164,
57500: 29159,
57501: 29173,
57502: 29180,
57503: 29177,
57504: 29183,
57505: 29197,
57506: 29200,
57507: 29211,
57508: 29224,
57509: 29229,
57510: 29228,
57511: 29232,
57512: 29234,
57513: 29243,
57514: 29244,
57515: 29247,
57516: 29248,
57517: 29254,
57518: 29259,
57519: 29272,
57520: 29300,
57521: 29310,
57522: 29314,
57523: 29313,
57524: 29319,
57525: 29330,
57526: 29334,
57527: 29346,
57528: 29351,
57529: 29369,
57530: 29362,
57531: 29379,
57532: 29382,
57533: 29380,
57534: 29390,
57535: 29394,
57536: 29410,
57537: 29408,
57538: 29409,
57539: 29433,
57540: 29431,
57541: 20495,
57542: 29463,
57543: 29450,
57544: 29468,
57545: 29462,
57546: 29469,
57547: 29492,
57548: 29487,
57549: 29481,
57550: 29477,
57551: 29502,
57552: 29518,
57553: 29519,
57554: 40664,
57555: 29527,
57556: 29546,
57557: 29544,
57558: 29552,
57559: 29560,
57560: 29557,
57561: 29563,
57562: 29562,
57563: 29640,
57564: 29619,
57565: 29646,
57566: 29627,
57567: 29632,
57568: 29669,
57569: 29678,
57570: 29662,
57571: 29858,
57572: 29701,
57573: 29807,
57574: 29733,
57575: 29688,
57576: 29746,
57577: 29754,
57578: 29781,
57579: 29759,
57580: 29791,
57581: 29785,
57582: 29761,
57583: 29788,
57584: 29801,
57585: 29808,
57586: 29795,
57587: 29802,
57588: 29814,
57589: 29822,
57590: 29835,
57591: 29854,
57592: 29863,
57593: 29898,
57594: 29903,
57595: 29908,
57596: 29681,
57664: 29920,
57665: 29923,
57666: 29927,
57667: 29929,
57668: 29934,
57669: 29938,
57670: 29936,
57671: 29937,
57672: 29944,
57673: 29943,
57674: 29956,
57675: 29955,
57676: 29957,
57677: 29964,
57678: 29966,
57679: 29965,
57680: 29973,
57681: 29971,
57682: 29982,
57683: 29990,
57684: 29996,
57685: 30012,
57686: 30020,
57687: 30029,
57688: 30026,
57689: 30025,
57690: 30043,
57691: 30022,
57692: 30042,
57693: 30057,
57694: 30052,
57695: 30055,
57696: 30059,
57697: 30061,
57698: 30072,
57699: 30070,
57700: 30086,
57701: 30087,
57702: 30068,
57703: 30090,
57704: 30089,
57705: 30082,
57706: 30100,
57707: 30106,
57708: 30109,
57709: 30117,
57710: 30115,
57711: 30146,
57712: 30131,
57713: 30147,
57714: 30133,
57715: 30141,
57716: 30136,
57717: 30140,
57718: 30129,
57719: 30157,
57720: 30154,
57721: 30162,
57722: 30169,
57723: 30179,
57724: 30174,
57725: 30206,
57726: 30207,
57728: 30204,
57729: 30209,
57730: 30192,
57731: 30202,
57732: 30194,
57733: 30195,
57734: 30219,
57735: 30221,
57736: 30217,
57737: 30239,
57738: 30247,
57739: 30240,
57740: 30241,
57741: 30242,
57742: 30244,
57743: 30260,
57744: 30256,
57745: 30267,
57746: 30279,
57747: 30280,
57748: 30278,
57749: 30300,
57750: 30296,
57751: 30305,
57752: 30306,
57753: 30312,
57754: 30313,
57755: 30314,
57756: 30311,
57757: 30316,
57758: 30320,
57759: 30322,
57760: 30326,
57761: 30328,
57762: 30332,
57763: 30336,
57764: 30339,
57765: 30344,
57766: 30347,
57767: 30350,
57768: 30358,
57769: 30355,
57770: 30361,
57771: 30362,
57772: 30384,
57773: 30388,
57774: 30392,
57775: 30393,
57776: 30394,
57777: 30402,
57778: 30413,
57779: 30422,
57780: 30418,
57781: 30430,
57782: 30433,
57783: 30437,
57784: 30439,
57785: 30442,
57786: 34351,
57787: 30459,
57788: 30472,
57789: 30471,
57790: 30468,
57791: 30505,
57792: 30500,
57793: 30494,
57794: 30501,
57795: 30502,
57796: 30491,
57797: 30519,
57798: 30520,
57799: 30535,
57800: 30554,
57801: 30568,
57802: 30571,
57803: 30555,
57804: 30565,
57805: 30591,
57806: 30590,
57807: 30585,
57808: 30606,
57809: 30603,
57810: 30609,
57811: 30624,
57812: 30622,
57813: 30640,
57814: 30646,
57815: 30649,
57816: 30655,
57817: 30652,
57818: 30653,
57819: 30651,
57820: 30663,
57821: 30669,
57822: 30679,
57823: 30682,
57824: 30684,
57825: 30691,
57826: 30702,
57827: 30716,
57828: 30732,
57829: 30738,
57830: 31014,
57831: 30752,
57832: 31018,
57833: 30789,
57834: 30862,
57835: 30836,
57836: 30854,
57837: 30844,
57838: 30874,
57839: 30860,
57840: 30883,
57841: 30901,
57842: 30890,
57843: 30895,
57844: 30929,
57845: 30918,
57846: 30923,
57847: 30932,
57848: 30910,
57849: 30908,
57850: 30917,
57851: 30922,
57852: 30956,
57920: 30951,
57921: 30938,
57922: 30973,
57923: 30964,
57924: 30983,
57925: 30994,
57926: 30993,
57927: 31001,
57928: 31020,
57929: 31019,
57930: 31040,
57931: 31072,
57932: 31063,
57933: 31071,
57934: 31066,
57935: 31061,
57936: 31059,
57937: 31098,
57938: 31103,
57939: 31114,
57940: 31133,
57941: 31143,
57942: 40779,
57943: 31146,
57944: 31150,
57945: 31155,
57946: 31161,
57947: 31162,
57948: 31177,
57949: 31189,
57950: 31207,
57951: 31212,
57952: 31201,
57953: 31203,
57954: 31240,
57955: 31245,
57956: 31256,
57957: 31257,
57958: 31264,
57959: 31263,
57960: 31104,
57961: 31281,
57962: 31291,
57963: 31294,
57964: 31287,
57965: 31299,
57966: 31319,
57967: 31305,
57968: 31329,
57969: 31330,
57970: 31337,
57971: 40861,
57972: 31344,
57973: 31353,
57974: 31357,
57975: 31368,
57976: 31383,
57977: 31381,
57978: 31384,
57979: 31382,
57980: 31401,
57981: 31432,
57982: 31408,
57984: 31414,
57985: 31429,
57986: 31428,
57987: 31423,
57988: 36995,
57989: 31431,
57990: 31434,
57991: 31437,
57992: 31439,
57993: 31445,
57994: 31443,
57995: 31449,
57996: 31450,
57997: 31453,
57998: 31457,
57999: 31458,
58e3: 31462,
58001: 31469,
58002: 31472,
58003: 31490,
58004: 31503,
58005: 31498,
58006: 31494,
58007: 31539,
58008: 31512,
58009: 31513,
58010: 31518,
58011: 31541,
58012: 31528,
58013: 31542,
58014: 31568,
58015: 31610,
58016: 31492,
58017: 31565,
58018: 31499,
58019: 31564,
58020: 31557,
58021: 31605,
58022: 31589,
58023: 31604,
58024: 31591,
58025: 31600,
58026: 31601,
58027: 31596,
58028: 31598,
58029: 31645,
58030: 31640,
58031: 31647,
58032: 31629,
58033: 31644,
58034: 31642,
58035: 31627,
58036: 31634,
58037: 31631,
58038: 31581,
58039: 31641,
58040: 31691,
58041: 31681,
58042: 31692,
58043: 31695,
58044: 31668,
58045: 31686,
58046: 31709,
58047: 31721,
58048: 31761,
58049: 31764,
58050: 31718,
58051: 31717,
58052: 31840,
58053: 31744,
58054: 31751,
58055: 31763,
58056: 31731,
58057: 31735,
58058: 31767,
58059: 31757,
58060: 31734,
58061: 31779,
58062: 31783,
58063: 31786,
58064: 31775,
58065: 31799,
58066: 31787,
58067: 31805,
58068: 31820,
58069: 31811,
58070: 31828,
58071: 31823,
58072: 31808,
58073: 31824,
58074: 31832,
58075: 31839,
58076: 31844,
58077: 31830,
58078: 31845,
58079: 31852,
58080: 31861,
58081: 31875,
58082: 31888,
58083: 31908,
58084: 31917,
58085: 31906,
58086: 31915,
58087: 31905,
58088: 31912,
58089: 31923,
58090: 31922,
58091: 31921,
58092: 31918,
58093: 31929,
58094: 31933,
58095: 31936,
58096: 31941,
58097: 31938,
58098: 31960,
58099: 31954,
58100: 31964,
58101: 31970,
58102: 39739,
58103: 31983,
58104: 31986,
58105: 31988,
58106: 31990,
58107: 31994,
58108: 32006,
58176: 32002,
58177: 32028,
58178: 32021,
58179: 32010,
58180: 32069,
58181: 32075,
58182: 32046,
58183: 32050,
58184: 32063,
58185: 32053,
58186: 32070,
58187: 32115,
58188: 32086,
58189: 32078,
58190: 32114,
58191: 32104,
58192: 32110,
58193: 32079,
58194: 32099,
58195: 32147,
58196: 32137,
58197: 32091,
58198: 32143,
58199: 32125,
58200: 32155,
58201: 32186,
58202: 32174,
58203: 32163,
58204: 32181,
58205: 32199,
58206: 32189,
58207: 32171,
58208: 32317,
58209: 32162,
58210: 32175,
58211: 32220,
58212: 32184,
58213: 32159,
58214: 32176,
58215: 32216,
58216: 32221,
58217: 32228,
58218: 32222,
58219: 32251,
58220: 32242,
58221: 32225,
58222: 32261,
58223: 32266,
58224: 32291,
58225: 32289,
58226: 32274,
58227: 32305,
58228: 32287,
58229: 32265,
58230: 32267,
58231: 32290,
58232: 32326,
58233: 32358,
58234: 32315,
58235: 32309,
58236: 32313,
58237: 32323,
58238: 32311,
58240: 32306,
58241: 32314,
58242: 32359,
58243: 32349,
58244: 32342,
58245: 32350,
58246: 32345,
58247: 32346,
58248: 32377,
58249: 32362,
58250: 32361,
58251: 32380,
58252: 32379,
58253: 32387,
58254: 32213,
58255: 32381,
58256: 36782,
58257: 32383,
58258: 32392,
58259: 32393,
58260: 32396,
58261: 32402,
58262: 32400,
58263: 32403,
58264: 32404,
58265: 32406,
58266: 32398,
58267: 32411,
58268: 32412,
58269: 32568,
58270: 32570,
58271: 32581,
58272: 32588,
58273: 32589,
58274: 32590,
58275: 32592,
58276: 32593,
58277: 32597,
58278: 32596,
58279: 32600,
58280: 32607,
58281: 32608,
58282: 32616,
58283: 32617,
58284: 32615,
58285: 32632,
58286: 32642,
58287: 32646,
58288: 32643,
58289: 32648,
58290: 32647,
58291: 32652,
58292: 32660,
58293: 32670,
58294: 32669,
58295: 32666,
58296: 32675,
58297: 32687,
58298: 32690,
58299: 32697,
58300: 32686,
58301: 32694,
58302: 32696,
58303: 35697,
58304: 32709,
58305: 32710,
58306: 32714,
58307: 32725,
58308: 32724,
58309: 32737,
58310: 32742,
58311: 32745,
58312: 32755,
58313: 32761,
58314: 39132,
58315: 32774,
58316: 32772,
58317: 32779,
58318: 32786,
58319: 32792,
58320: 32793,
58321: 32796,
58322: 32801,
58323: 32808,
58324: 32831,
58325: 32827,
58326: 32842,
58327: 32838,
58328: 32850,
58329: 32856,
58330: 32858,
58331: 32863,
58332: 32866,
58333: 32872,
58334: 32883,
58335: 32882,
58336: 32880,
58337: 32886,
58338: 32889,
58339: 32893,
58340: 32895,
58341: 32900,
58342: 32902,
58343: 32901,
58344: 32923,
58345: 32915,
58346: 32922,
58347: 32941,
58348: 20880,
58349: 32940,
58350: 32987,
58351: 32997,
58352: 32985,
58353: 32989,
58354: 32964,
58355: 32986,
58356: 32982,
58357: 33033,
58358: 33007,
58359: 33009,
58360: 33051,
58361: 33065,
58362: 33059,
58363: 33071,
58364: 33099,
58432: 38539,
58433: 33094,
58434: 33086,
58435: 33107,
58436: 33105,
58437: 33020,
58438: 33137,
58439: 33134,
58440: 33125,
58441: 33126,
58442: 33140,
58443: 33155,
58444: 33160,
58445: 33162,
58446: 33152,
58447: 33154,
58448: 33184,
58449: 33173,
58450: 33188,
58451: 33187,
58452: 33119,
58453: 33171,
58454: 33193,
58455: 33200,
58456: 33205,
58457: 33214,
58458: 33208,
58459: 33213,
58460: 33216,
58461: 33218,
58462: 33210,
58463: 33225,
58464: 33229,
58465: 33233,
58466: 33241,
58467: 33240,
58468: 33224,
58469: 33242,
58470: 33247,
58471: 33248,
58472: 33255,
58473: 33274,
58474: 33275,
58475: 33278,
58476: 33281,
58477: 33282,
58478: 33285,
58479: 33287,
58480: 33290,
58481: 33293,
58482: 33296,
58483: 33302,
58484: 33321,
58485: 33323,
58486: 33336,
58487: 33331,
58488: 33344,
58489: 33369,
58490: 33368,
58491: 33373,
58492: 33370,
58493: 33375,
58494: 33380,
58496: 33378,
58497: 33384,
58498: 33386,
58499: 33387,
58500: 33326,
58501: 33393,
58502: 33399,
58503: 33400,
58504: 33406,
58505: 33421,
58506: 33426,
58507: 33451,
58508: 33439,
58509: 33467,
58510: 33452,
58511: 33505,
58512: 33507,
58513: 33503,
58514: 33490,
58515: 33524,
58516: 33523,
58517: 33530,
58518: 33683,
58519: 33539,
58520: 33531,
58521: 33529,
58522: 33502,
58523: 33542,
58524: 33500,
58525: 33545,
58526: 33497,
58527: 33589,
58528: 33588,
58529: 33558,
58530: 33586,
58531: 33585,
58532: 33600,
58533: 33593,
58534: 33616,
58535: 33605,
58536: 33583,
58537: 33579,
58538: 33559,
58539: 33560,
58540: 33669,
58541: 33690,
58542: 33706,
58543: 33695,
58544: 33698,
58545: 33686,
58546: 33571,
58547: 33678,
58548: 33671,
58549: 33674,
58550: 33660,
58551: 33717,
58552: 33651,
58553: 33653,
58554: 33696,
58555: 33673,
58556: 33704,
58557: 33780,
58558: 33811,
58559: 33771,
58560: 33742,
58561: 33789,
58562: 33795,
58563: 33752,
58564: 33803,
58565: 33729,
58566: 33783,
58567: 33799,
58568: 33760,
58569: 33778,
58570: 33805,
58571: 33826,
58572: 33824,
58573: 33725,
58574: 33848,
58575: 34054,
58576: 33787,
58577: 33901,
58578: 33834,
58579: 33852,
58580: 34138,
58581: 33924,
58582: 33911,
58583: 33899,
58584: 33965,
58585: 33902,
58586: 33922,
58587: 33897,
58588: 33862,
58589: 33836,
58590: 33903,
58591: 33913,
58592: 33845,
58593: 33994,
58594: 33890,
58595: 33977,
58596: 33983,
58597: 33951,
58598: 34009,
58599: 33997,
58600: 33979,
58601: 34010,
58602: 34e3,
58603: 33985,
58604: 33990,
58605: 34006,
58606: 33953,
58607: 34081,
58608: 34047,
58609: 34036,
58610: 34071,
58611: 34072,
58612: 34092,
58613: 34079,
58614: 34069,
58615: 34068,
58616: 34044,
58617: 34112,
58618: 34147,
58619: 34136,
58620: 34120,
58688: 34113,
58689: 34306,
58690: 34123,
58691: 34133,
58692: 34176,
58693: 34212,
58694: 34184,
58695: 34193,
58696: 34186,
58697: 34216,
58698: 34157,
58699: 34196,
58700: 34203,
58701: 34282,
58702: 34183,
58703: 34204,
58704: 34167,
58705: 34174,
58706: 34192,
58707: 34249,
58708: 34234,
58709: 34255,
58710: 34233,
58711: 34256,
58712: 34261,
58713: 34269,
58714: 34277,
58715: 34268,
58716: 34297,
58717: 34314,
58718: 34323,
58719: 34315,
58720: 34302,
58721: 34298,
58722: 34310,
58723: 34338,
58724: 34330,
58725: 34352,
58726: 34367,
58727: 34381,
58728: 20053,
58729: 34388,
58730: 34399,
58731: 34407,
58732: 34417,
58733: 34451,
58734: 34467,
58735: 34473,
58736: 34474,
58737: 34443,
58738: 34444,
58739: 34486,
58740: 34479,
58741: 34500,
58742: 34502,
58743: 34480,
58744: 34505,
58745: 34851,
58746: 34475,
58747: 34516,
58748: 34526,
58749: 34537,
58750: 34540,
58752: 34527,
58753: 34523,
58754: 34543,
58755: 34578,
58756: 34566,
58757: 34568,
58758: 34560,
58759: 34563,
58760: 34555,
58761: 34577,
58762: 34569,
58763: 34573,
58764: 34553,
58765: 34570,
58766: 34612,
58767: 34623,
58768: 34615,
58769: 34619,
58770: 34597,
58771: 34601,
58772: 34586,
58773: 34656,
58774: 34655,
58775: 34680,
58776: 34636,
58777: 34638,
58778: 34676,
58779: 34647,
58780: 34664,
58781: 34670,
58782: 34649,
58783: 34643,
58784: 34659,
58785: 34666,
58786: 34821,
58787: 34722,
58788: 34719,
58789: 34690,
58790: 34735,
58791: 34763,
58792: 34749,
58793: 34752,
58794: 34768,
58795: 38614,
58796: 34731,
58797: 34756,
58798: 34739,
58799: 34759,
58800: 34758,
58801: 34747,
58802: 34799,
58803: 34802,
58804: 34784,
58805: 34831,
58806: 34829,
58807: 34814,
58808: 34806,
58809: 34807,
58810: 34830,
58811: 34770,
58812: 34833,
58813: 34838,
58814: 34837,
58815: 34850,
58816: 34849,
58817: 34865,
58818: 34870,
58819: 34873,
58820: 34855,
58821: 34875,
58822: 34884,
58823: 34882,
58824: 34898,
58825: 34905,
58826: 34910,
58827: 34914,
58828: 34923,
58829: 34945,
58830: 34942,
58831: 34974,
58832: 34933,
58833: 34941,
58834: 34997,
58835: 34930,
58836: 34946,
58837: 34967,
58838: 34962,
58839: 34990,
58840: 34969,
58841: 34978,
58842: 34957,
58843: 34980,
58844: 34992,
58845: 35007,
58846: 34993,
58847: 35011,
58848: 35012,
58849: 35028,
58850: 35032,
58851: 35033,
58852: 35037,
58853: 35065,
58854: 35074,
58855: 35068,
58856: 35060,
58857: 35048,
58858: 35058,
58859: 35076,
58860: 35084,
58861: 35082,
58862: 35091,
58863: 35139,
58864: 35102,
58865: 35109,
58866: 35114,
58867: 35115,
58868: 35137,
58869: 35140,
58870: 35131,
58871: 35126,
58872: 35128,
58873: 35148,
58874: 35101,
58875: 35168,
58876: 35166,
58944: 35174,
58945: 35172,
58946: 35181,
58947: 35178,
58948: 35183,
58949: 35188,
58950: 35191,
58951: 35198,
58952: 35203,
58953: 35208,
58954: 35210,
58955: 35219,
58956: 35224,
58957: 35233,
58958: 35241,
58959: 35238,
58960: 35244,
58961: 35247,
58962: 35250,
58963: 35258,
58964: 35261,
58965: 35263,
58966: 35264,
58967: 35290,
58968: 35292,
58969: 35293,
58970: 35303,
58971: 35316,
58972: 35320,
58973: 35331,
58974: 35350,
58975: 35344,
58976: 35340,
58977: 35355,
58978: 35357,
58979: 35365,
58980: 35382,
58981: 35393,
58982: 35419,
58983: 35410,
58984: 35398,
58985: 35400,
58986: 35452,
58987: 35437,
58988: 35436,
58989: 35426,
58990: 35461,
58991: 35458,
58992: 35460,
58993: 35496,
58994: 35489,
58995: 35473,
58996: 35493,
58997: 35494,
58998: 35482,
58999: 35491,
59e3: 35524,
59001: 35533,
59002: 35522,
59003: 35546,
59004: 35563,
59005: 35571,
59006: 35559,
59008: 35556,
59009: 35569,
59010: 35604,
59011: 35552,
59012: 35554,
59013: 35575,
59014: 35550,
59015: 35547,
59016: 35596,
59017: 35591,
59018: 35610,
59019: 35553,
59020: 35606,
59021: 35600,
59022: 35607,
59023: 35616,
59024: 35635,
59025: 38827,
59026: 35622,
59027: 35627,
59028: 35646,
59029: 35624,
59030: 35649,
59031: 35660,
59032: 35663,
59033: 35662,
59034: 35657,
59035: 35670,
59036: 35675,
59037: 35674,
59038: 35691,
59039: 35679,
59040: 35692,
59041: 35695,
59042: 35700,
59043: 35709,
59044: 35712,
59045: 35724,
59046: 35726,
59047: 35730,
59048: 35731,
59049: 35734,
59050: 35737,
59051: 35738,
59052: 35898,
59053: 35905,
59054: 35903,
59055: 35912,
59056: 35916,
59057: 35918,
59058: 35920,
59059: 35925,
59060: 35938,
59061: 35948,
59062: 35960,
59063: 35962,
59064: 35970,
59065: 35977,
59066: 35973,
59067: 35978,
59068: 35981,
59069: 35982,
59070: 35988,
59071: 35964,
59072: 35992,
59073: 25117,
59074: 36013,
59075: 36010,
59076: 36029,
59077: 36018,
59078: 36019,
59079: 36014,
59080: 36022,
59081: 36040,
59082: 36033,
59083: 36068,
59084: 36067,
59085: 36058,
59086: 36093,
59087: 36090,
59088: 36091,
59089: 36100,
59090: 36101,
59091: 36106,
59092: 36103,
59093: 36111,
59094: 36109,
59095: 36112,
59096: 40782,
59097: 36115,
59098: 36045,
59099: 36116,
59100: 36118,
59101: 36199,
59102: 36205,
59103: 36209,
59104: 36211,
59105: 36225,
59106: 36249,
59107: 36290,
59108: 36286,
59109: 36282,
59110: 36303,
59111: 36314,
59112: 36310,
59113: 36300,
59114: 36315,
59115: 36299,
59116: 36330,
59117: 36331,
59118: 36319,
59119: 36323,
59120: 36348,
59121: 36360,
59122: 36361,
59123: 36351,
59124: 36381,
59125: 36382,
59126: 36368,
59127: 36383,
59128: 36418,
59129: 36405,
59130: 36400,
59131: 36404,
59132: 36426,
59200: 36423,
59201: 36425,
59202: 36428,
59203: 36432,
59204: 36424,
59205: 36441,
59206: 36452,
59207: 36448,
59208: 36394,
59209: 36451,
59210: 36437,
59211: 36470,
59212: 36466,
59213: 36476,
59214: 36481,
59215: 36487,
59216: 36485,
59217: 36484,
59218: 36491,
59219: 36490,
59220: 36499,
59221: 36497,
59222: 36500,
59223: 36505,
59224: 36522,
59225: 36513,
59226: 36524,
59227: 36528,
59228: 36550,
59229: 36529,
59230: 36542,
59231: 36549,
59232: 36552,
59233: 36555,
59234: 36571,
59235: 36579,
59236: 36604,
59237: 36603,
59238: 36587,
59239: 36606,
59240: 36618,
59241: 36613,
59242: 36629,
59243: 36626,
59244: 36633,
59245: 36627,
59246: 36636,
59247: 36639,
59248: 36635,
59249: 36620,
59250: 36646,
59251: 36659,
59252: 36667,
59253: 36665,
59254: 36677,
59255: 36674,
59256: 36670,
59257: 36684,
59258: 36681,
59259: 36678,
59260: 36686,
59261: 36695,
59262: 36700,
59264: 36706,
59265: 36707,
59266: 36708,
59267: 36764,
59268: 36767,
59269: 36771,
59270: 36781,
59271: 36783,
59272: 36791,
59273: 36826,
59274: 36837,
59275: 36834,
59276: 36842,
59277: 36847,
59278: 36999,
59279: 36852,
59280: 36869,
59281: 36857,
59282: 36858,
59283: 36881,
59284: 36885,
59285: 36897,
59286: 36877,
59287: 36894,
59288: 36886,
59289: 36875,
59290: 36903,
59291: 36918,
59292: 36917,
59293: 36921,
59294: 36856,
59295: 36943,
59296: 36944,
59297: 36945,
59298: 36946,
59299: 36878,
59300: 36937,
59301: 36926,
59302: 36950,
59303: 36952,
59304: 36958,
59305: 36968,
59306: 36975,
59307: 36982,
59308: 38568,
59309: 36978,
59310: 36994,
59311: 36989,
59312: 36993,
59313: 36992,
59314: 37002,
59315: 37001,
59316: 37007,
59317: 37032,
59318: 37039,
59319: 37041,
59320: 37045,
59321: 37090,
59322: 37092,
59323: 25160,
59324: 37083,
59325: 37122,
59326: 37138,
59327: 37145,
59328: 37170,
59329: 37168,
59330: 37194,
59331: 37206,
59332: 37208,
59333: 37219,
59334: 37221,
59335: 37225,
59336: 37235,
59337: 37234,
59338: 37259,
59339: 37257,
59340: 37250,
59341: 37282,
59342: 37291,
59343: 37295,
59344: 37290,
59345: 37301,
59346: 37300,
59347: 37306,
59348: 37312,
59349: 37313,
59350: 37321,
59351: 37323,
59352: 37328,
59353: 37334,
59354: 37343,
59355: 37345,
59356: 37339,
59357: 37372,
59358: 37365,
59359: 37366,
59360: 37406,
59361: 37375,
59362: 37396,
59363: 37420,
59364: 37397,
59365: 37393,
59366: 37470,
59367: 37463,
59368: 37445,
59369: 37449,
59370: 37476,
59371: 37448,
59372: 37525,
59373: 37439,
59374: 37451,
59375: 37456,
59376: 37532,
59377: 37526,
59378: 37523,
59379: 37531,
59380: 37466,
59381: 37583,
59382: 37561,
59383: 37559,
59384: 37609,
59385: 37647,
59386: 37626,
59387: 37700,
59388: 37678,
59456: 37657,
59457: 37666,
59458: 37658,
59459: 37667,
59460: 37690,
59461: 37685,
59462: 37691,
59463: 37724,
59464: 37728,
59465: 37756,
59466: 37742,
59467: 37718,
59468: 37808,
59469: 37804,
59470: 37805,
59471: 37780,
59472: 37817,
59473: 37846,
59474: 37847,
59475: 37864,
59476: 37861,
59477: 37848,
59478: 37827,
59479: 37853,
59480: 37840,
59481: 37832,
59482: 37860,
59483: 37914,
59484: 37908,
59485: 37907,
59486: 37891,
59487: 37895,
59488: 37904,
59489: 37942,
59490: 37931,
59491: 37941,
59492: 37921,
59493: 37946,
59494: 37953,
59495: 37970,
59496: 37956,
59497: 37979,
59498: 37984,
59499: 37986,
59500: 37982,
59501: 37994,
59502: 37417,
59503: 38e3,
59504: 38005,
59505: 38007,
59506: 38013,
59507: 37978,
59508: 38012,
59509: 38014,
59510: 38017,
59511: 38015,
59512: 38274,
59513: 38279,
59514: 38282,
59515: 38292,
59516: 38294,
59517: 38296,
59518: 38297,
59520: 38304,
59521: 38312,
59522: 38311,
59523: 38317,
59524: 38332,
59525: 38331,
59526: 38329,
59527: 38334,
59528: 38346,
59529: 28662,
59530: 38339,
59531: 38349,
59532: 38348,
59533: 38357,
59534: 38356,
59535: 38358,
59536: 38364,
59537: 38369,
59538: 38373,
59539: 38370,
59540: 38433,
59541: 38440,
59542: 38446,
59543: 38447,
59544: 38466,
59545: 38476,
59546: 38479,
59547: 38475,
59548: 38519,
59549: 38492,
59550: 38494,
59551: 38493,
59552: 38495,
59553: 38502,
59554: 38514,
59555: 38508,
59556: 38541,
59557: 38552,
59558: 38549,
59559: 38551,
59560: 38570,
59561: 38567,
59562: 38577,
59563: 38578,
59564: 38576,
59565: 38580,
59566: 38582,
59567: 38584,
59568: 38585,
59569: 38606,
59570: 38603,
59571: 38601,
59572: 38605,
59573: 35149,
59574: 38620,
59575: 38669,
59576: 38613,
59577: 38649,
59578: 38660,
59579: 38662,
59580: 38664,
59581: 38675,
59582: 38670,
59583: 38673,
59584: 38671,
59585: 38678,
59586: 38681,
59587: 38692,
59588: 38698,
59589: 38704,
59590: 38713,
59591: 38717,
59592: 38718,
59593: 38724,
59594: 38726,
59595: 38728,
59596: 38722,
59597: 38729,
59598: 38748,
59599: 38752,
59600: 38756,
59601: 38758,
59602: 38760,
59603: 21202,
59604: 38763,
59605: 38769,
59606: 38777,
59607: 38789,
59608: 38780,
59609: 38785,
59610: 38778,
59611: 38790,
59612: 38795,
59613: 38799,
59614: 38800,
59615: 38812,
59616: 38824,
59617: 38822,
59618: 38819,
59619: 38835,
59620: 38836,
59621: 38851,
59622: 38854,
59623: 38856,
59624: 38859,
59625: 38876,
59626: 38893,
59627: 40783,
59628: 38898,
59629: 31455,
59630: 38902,
59631: 38901,
59632: 38927,
59633: 38924,
59634: 38968,
59635: 38948,
59636: 38945,
59637: 38967,
59638: 38973,
59639: 38982,
59640: 38991,
59641: 38987,
59642: 39019,
59643: 39023,
59644: 39024,
59712: 39025,
59713: 39028,
59714: 39027,
59715: 39082,
59716: 39087,
59717: 39089,
59718: 39094,
59719: 39108,
59720: 39107,
59721: 39110,
59722: 39145,
59723: 39147,
59724: 39171,
59725: 39177,
59726: 39186,
59727: 39188,
59728: 39192,
59729: 39201,
59730: 39197,
59731: 39198,
59732: 39204,
59733: 39200,
59734: 39212,
59735: 39214,
59736: 39229,
59737: 39230,
59738: 39234,
59739: 39241,
59740: 39237,
59741: 39248,
59742: 39243,
59743: 39249,
59744: 39250,
59745: 39244,
59746: 39253,
59747: 39319,
59748: 39320,
59749: 39333,
59750: 39341,
59751: 39342,
59752: 39356,
59753: 39391,
59754: 39387,
59755: 39389,
59756: 39384,
59757: 39377,
59758: 39405,
59759: 39406,
59760: 39409,
59761: 39410,
59762: 39419,
59763: 39416,
59764: 39425,
59765: 39439,
59766: 39429,
59767: 39394,
59768: 39449,
59769: 39467,
59770: 39479,
59771: 39493,
59772: 39490,
59773: 39488,
59774: 39491,
59776: 39486,
59777: 39509,
59778: 39501,
59779: 39515,
59780: 39511,
59781: 39519,
59782: 39522,
59783: 39525,
59784: 39524,
59785: 39529,
59786: 39531,
59787: 39530,
59788: 39597,
59789: 39600,
59790: 39612,
59791: 39616,
59792: 39631,
59793: 39633,
59794: 39635,
59795: 39636,
59796: 39646,
59797: 39647,
59798: 39650,
59799: 39651,
59800: 39654,
59801: 39663,
59802: 39659,
59803: 39662,
59804: 39668,
59805: 39665,
59806: 39671,
59807: 39675,
59808: 39686,
59809: 39704,
59810: 39706,
59811: 39711,
59812: 39714,
59813: 39715,
59814: 39717,
59815: 39719,
59816: 39720,
59817: 39721,
59818: 39722,
59819: 39726,
59820: 39727,
59821: 39730,
59822: 39748,
59823: 39747,
59824: 39759,
59825: 39757,
59826: 39758,
59827: 39761,
59828: 39768,
59829: 39796,
59830: 39827,
59831: 39811,
59832: 39825,
59833: 39830,
59834: 39831,
59835: 39839,
59836: 39840,
59837: 39848,
59838: 39860,
59839: 39872,
59840: 39882,
59841: 39865,
59842: 39878,
59843: 39887,
59844: 39889,
59845: 39890,
59846: 39907,
59847: 39906,
59848: 39908,
59849: 39892,
59850: 39905,
59851: 39994,
59852: 39922,
59853: 39921,
59854: 39920,
59855: 39957,
59856: 39956,
59857: 39945,
59858: 39955,
59859: 39948,
59860: 39942,
59861: 39944,
59862: 39954,
59863: 39946,
59864: 39940,
59865: 39982,
59866: 39963,
59867: 39973,
59868: 39972,
59869: 39969,
59870: 39984,
59871: 40007,
59872: 39986,
59873: 40006,
59874: 39998,
59875: 40026,
59876: 40032,
59877: 40039,
59878: 40054,
59879: 40056,
59880: 40167,
59881: 40172,
59882: 40176,
59883: 40201,
59884: 40200,
59885: 40171,
59886: 40195,
59887: 40198,
59888: 40234,
59889: 40230,
59890: 40367,
59891: 40227,
59892: 40223,
59893: 40260,
59894: 40213,
59895: 40210,
59896: 40257,
59897: 40255,
59898: 40254,
59899: 40262,
59900: 40264,
59968: 40285,
59969: 40286,
59970: 40292,
59971: 40273,
59972: 40272,
59973: 40281,
59974: 40306,
59975: 40329,
59976: 40327,
59977: 40363,
59978: 40303,
59979: 40314,
59980: 40346,
59981: 40356,
59982: 40361,
59983: 40370,
59984: 40388,
59985: 40385,
59986: 40379,
59987: 40376,
59988: 40378,
59989: 40390,
59990: 40399,
59991: 40386,
59992: 40409,
59993: 40403,
59994: 40440,
59995: 40422,
59996: 40429,
59997: 40431,
59998: 40445,
59999: 40474,
6e4: 40475,
60001: 40478,
60002: 40565,
60003: 40569,
60004: 40573,
60005: 40577,
60006: 40584,
60007: 40587,
60008: 40588,
60009: 40594,
60010: 40597,
60011: 40593,
60012: 40605,
60013: 40613,
60014: 40617,
60015: 40632,
60016: 40618,
60017: 40621,
60018: 38753,
60019: 40652,
60020: 40654,
60021: 40655,
60022: 40656,
60023: 40660,
60024: 40668,
60025: 40670,
60026: 40669,
60027: 40672,
60028: 40677,
60029: 40680,
60030: 40687,
60032: 40692,
60033: 40694,
60034: 40695,
60035: 40697,
60036: 40699,
60037: 40700,
60038: 40701,
60039: 40711,
60040: 40712,
60041: 30391,
60042: 40725,
60043: 40737,
60044: 40748,
60045: 40766,
60046: 40778,
60047: 40786,
60048: 40788,
60049: 40803,
60050: 40799,
60051: 40800,
60052: 40801,
60053: 40806,
60054: 40807,
60055: 40812,
60056: 40810,
60057: 40823,
60058: 40818,
60059: 40822,
60060: 40853,
60061: 40860,
60062: 40864,
60063: 22575,
60064: 27079,
60065: 36953,
60066: 29796,
60067: 20956,
60068: 29081,
60736: 32394,
60737: 35100,
60738: 37704,
60739: 37512,
60740: 34012,
60741: 20425,
60742: 28859,
60743: 26161,
60744: 26824,
60745: 37625,
60746: 26363,
60747: 24389,
60748: 20008,
60749: 20193,
60750: 20220,
60751: 20224,
60752: 20227,
60753: 20281,
60754: 20310,
60755: 20370,
60756: 20362,
60757: 20378,
60758: 20372,
60759: 20429,
60760: 20544,
60761: 20514,
60762: 20479,
60763: 20510,
60764: 20550,
60765: 20592,
60766: 20546,
60767: 20628,
60768: 20724,
60769: 20696,
60770: 20810,
60771: 20836,
60772: 20893,
60773: 20926,
60774: 20972,
60775: 21013,
60776: 21148,
60777: 21158,
60778: 21184,
60779: 21211,
60780: 21248,
60781: 21255,
60782: 21284,
60783: 21362,
60784: 21395,
60785: 21426,
60786: 21469,
60787: 64014,
60788: 21660,
60789: 21642,
60790: 21673,
60791: 21759,
60792: 21894,
60793: 22361,
60794: 22373,
60795: 22444,
60796: 22472,
60797: 22471,
60798: 64015,
60800: 64016,
60801: 22686,
60802: 22706,
60803: 22795,
60804: 22867,
60805: 22875,
60806: 22877,
60807: 22883,
60808: 22948,
60809: 22970,
60810: 23382,
60811: 23488,
60812: 29999,
60813: 23512,
60814: 23532,
60815: 23582,
60816: 23718,
60817: 23738,
60818: 23797,
60819: 23847,
60820: 23891,
60821: 64017,
60822: 23874,
60823: 23917,
60824: 23992,
60825: 23993,
60826: 24016,
60827: 24353,
60828: 24372,
60829: 24423,
60830: 24503,
60831: 24542,
60832: 24669,
60833: 24709,
60834: 24714,
60835: 24798,
60836: 24789,
60837: 24864,
60838: 24818,
60839: 24849,
60840: 24887,
60841: 24880,
60842: 24984,
60843: 25107,
60844: 25254,
60845: 25589,
60846: 25696,
60847: 25757,
60848: 25806,
60849: 25934,
60850: 26112,
60851: 26133,
60852: 26171,
60853: 26121,
60854: 26158,
60855: 26142,
60856: 26148,
60857: 26213,
60858: 26199,
60859: 26201,
60860: 64018,
60861: 26227,
60862: 26265,
60863: 26272,
60864: 26290,
60865: 26303,
60866: 26362,
60867: 26382,
60868: 63785,
60869: 26470,
60870: 26555,
60871: 26706,
60872: 26560,
60873: 26625,
60874: 26692,
60875: 26831,
60876: 64019,
60877: 26984,
60878: 64020,
60879: 27032,
60880: 27106,
60881: 27184,
60882: 27243,
60883: 27206,
60884: 27251,
60885: 27262,
60886: 27362,
60887: 27364,
60888: 27606,
60889: 27711,
60890: 27740,
60891: 27782,
60892: 27759,
60893: 27866,
60894: 27908,
60895: 28039,
60896: 28015,
60897: 28054,
60898: 28076,
60899: 28111,
60900: 28152,
60901: 28146,
60902: 28156,
60903: 28217,
60904: 28252,
60905: 28199,
60906: 28220,
60907: 28351,
60908: 28552,
60909: 28597,
60910: 28661,
60911: 28677,
60912: 28679,
60913: 28712,
60914: 28805,
60915: 28843,
60916: 28943,
60917: 28932,
60918: 29020,
60919: 28998,
60920: 28999,
60921: 64021,
60922: 29121,
60923: 29182,
60924: 29361,
60992: 29374,
60993: 29476,
60994: 64022,
60995: 29559,
60996: 29629,
60997: 29641,
60998: 29654,
60999: 29667,
61e3: 29650,
61001: 29703,
61002: 29685,
61003: 29734,
61004: 29738,
61005: 29737,
61006: 29742,
61007: 29794,
61008: 29833,
61009: 29855,
61010: 29953,
61011: 30063,
61012: 30338,
61013: 30364,
61014: 30366,
61015: 30363,
61016: 30374,
61017: 64023,
61018: 30534,
61019: 21167,
61020: 30753,
61021: 30798,
61022: 30820,
61023: 30842,
61024: 31024,
61025: 64024,
61026: 64025,
61027: 64026,
61028: 31124,
61029: 64027,
61030: 31131,
61031: 31441,
61032: 31463,
61033: 64028,
61034: 31467,
61035: 31646,
61036: 64029,
61037: 32072,
61038: 32092,
61039: 32183,
61040: 32160,
61041: 32214,
61042: 32338,
61043: 32583,
61044: 32673,
61045: 64030,
61046: 33537,
61047: 33634,
61048: 33663,
61049: 33735,
61050: 33782,
61051: 33864,
61052: 33972,
61053: 34131,
61054: 34137,
61056: 34155,
61057: 64031,
61058: 34224,
61059: 64032,
61060: 64033,
61061: 34823,
61062: 35061,
61063: 35346,
61064: 35383,
61065: 35449,
61066: 35495,
61067: 35518,
61068: 35551,
61069: 64034,
61070: 35574,
61071: 35667,
61072: 35711,
61073: 36080,
61074: 36084,
61075: 36114,
61076: 36214,
61077: 64035,
61078: 36559,
61079: 64036,
61080: 64037,
61081: 36967,
61082: 37086,
61083: 64038,
61084: 37141,
61085: 37159,
61086: 37338,
61087: 37335,
61088: 37342,
61089: 37357,
61090: 37358,
61091: 37348,
61092: 37349,
61093: 37382,
61094: 37392,
61095: 37386,
61096: 37434,
61097: 37440,
61098: 37436,
61099: 37454,
61100: 37465,
61101: 37457,
61102: 37433,
61103: 37479,
61104: 37543,
61105: 37495,
61106: 37496,
61107: 37607,
61108: 37591,
61109: 37593,
61110: 37584,
61111: 64039,
61112: 37589,
61113: 37600,
61114: 37587,
61115: 37669,
61116: 37665,
61117: 37627,
61118: 64040,
61119: 37662,
61120: 37631,
61121: 37661,
61122: 37634,
61123: 37744,
61124: 37719,
61125: 37796,
61126: 37830,
61127: 37854,
61128: 37880,
61129: 37937,
61130: 37957,
61131: 37960,
61132: 38290,
61133: 63964,
61134: 64041,
61135: 38557,
61136: 38575,
61137: 38707,
61138: 38715,
61139: 38723,
61140: 38733,
61141: 38735,
61142: 38737,
61143: 38741,
61144: 38999,
61145: 39013,
61146: 64042,
61147: 64043,
61148: 39207,
61149: 64044,
61150: 39326,
61151: 39502,
61152: 39641,
61153: 39644,
61154: 39797,
61155: 39794,
61156: 39823,
61157: 39857,
61158: 39867,
61159: 39936,
61160: 40304,
61161: 40299,
61162: 64045,
61163: 40473,
61164: 40657,
61167: 8560,
61168: 8561,
61169: 8562,
61170: 8563,
61171: 8564,
61172: 8565,
61173: 8566,
61174: 8567,
61175: 8568,
61176: 8569,
61177: 65506,
61178: 65508,
61179: 65287,
61180: 65282,
61504: 57344,
61505: 57345,
61506: 57346,
61507: 57347,
61508: 57348,
61509: 57349,
61510: 57350,
61511: 57351,
61512: 57352,
61513: 57353,
61514: 57354,
61515: 57355,
61516: 57356,
61517: 57357,
61518: 57358,
61519: 57359,
61520: 57360,
61521: 57361,
61522: 57362,
61523: 57363,
61524: 57364,
61525: 57365,
61526: 57366,
61527: 57367,
61528: 57368,
61529: 57369,
61530: 57370,
61531: 57371,
61532: 57372,
61533: 57373,
61534: 57374,
61535: 57375,
61536: 57376,
61537: 57377,
61538: 57378,
61539: 57379,
61540: 57380,
61541: 57381,
61542: 57382,
61543: 57383,
61544: 57384,
61545: 57385,
61546: 57386,
61547: 57387,
61548: 57388,
61549: 57389,
61550: 57390,
61551: 57391,
61552: 57392,
61553: 57393,
61554: 57394,
61555: 57395,
61556: 57396,
61557: 57397,
61558: 57398,
61559: 57399,
61560: 57400,
61561: 57401,
61562: 57402,
61563: 57403,
61564: 57404,
61565: 57405,
61566: 57406,
61568: 57407,
61569: 57408,
61570: 57409,
61571: 57410,
61572: 57411,
61573: 57412,
61574: 57413,
61575: 57414,
61576: 57415,
61577: 57416,
61578: 57417,
61579: 57418,
61580: 57419,
61581: 57420,
61582: 57421,
61583: 57422,
61584: 57423,
61585: 57424,
61586: 57425,
61587: 57426,
61588: 57427,
61589: 57428,
61590: 57429,
61591: 57430,
61592: 57431,
61593: 57432,
61594: 57433,
61595: 57434,
61596: 57435,
61597: 57436,
61598: 57437,
61599: 57438,
61600: 57439,
61601: 57440,
61602: 57441,
61603: 57442,
61604: 57443,
61605: 57444,
61606: 57445,
61607: 57446,
61608: 57447,
61609: 57448,
61610: 57449,
61611: 57450,
61612: 57451,
61613: 57452,
61614: 57453,
61615: 57454,
61616: 57455,
61617: 57456,
61618: 57457,
61619: 57458,
61620: 57459,
61621: 57460,
61622: 57461,
61623: 57462,
61624: 57463,
61625: 57464,
61626: 57465,
61627: 57466,
61628: 57467,
61629: 57468,
61630: 57469,
61631: 57470,
61632: 57471,
61633: 57472,
61634: 57473,
61635: 57474,
61636: 57475,
61637: 57476,
61638: 57477,
61639: 57478,
61640: 57479,
61641: 57480,
61642: 57481,
61643: 57482,
61644: 57483,
61645: 57484,
61646: 57485,
61647: 57486,
61648: 57487,
61649: 57488,
61650: 57489,
61651: 57490,
61652: 57491,
61653: 57492,
61654: 57493,
61655: 57494,
61656: 57495,
61657: 57496,
61658: 57497,
61659: 57498,
61660: 57499,
61661: 57500,
61662: 57501,
61663: 57502,
61664: 57503,
61665: 57504,
61666: 57505,
61667: 57506,
61668: 57507,
61669: 57508,
61670: 57509,
61671: 57510,
61672: 57511,
61673: 57512,
61674: 57513,
61675: 57514,
61676: 57515,
61677: 57516,
61678: 57517,
61679: 57518,
61680: 57519,
61681: 57520,
61682: 57521,
61683: 57522,
61684: 57523,
61685: 57524,
61686: 57525,
61687: 57526,
61688: 57527,
61689: 57528,
61690: 57529,
61691: 57530,
61692: 57531,
61760: 57532,
61761: 57533,
61762: 57534,
61763: 57535,
61764: 57536,
61765: 57537,
61766: 57538,
61767: 57539,
61768: 57540,
61769: 57541,
61770: 57542,
61771: 57543,
61772: 57544,
61773: 57545,
61774: 57546,
61775: 57547,
61776: 57548,
61777: 57549,
61778: 57550,
61779: 57551,
61780: 57552,
61781: 57553,
61782: 57554,
61783: 57555,
61784: 57556,
61785: 57557,
61786: 57558,
61787: 57559,
61788: 57560,
61789: 57561,
61790: 57562,
61791: 57563,
61792: 57564,
61793: 57565,
61794: 57566,
61795: 57567,
61796: 57568,
61797: 57569,
61798: 57570,
61799: 57571,
61800: 57572,
61801: 57573,
61802: 57574,
61803: 57575,
61804: 57576,
61805: 57577,
61806: 57578,
61807: 57579,
61808: 57580,
61809: 57581,
61810: 57582,
61811: 57583,
61812: 57584,
61813: 57585,
61814: 57586,
61815: 57587,
61816: 57588,
61817: 57589,
61818: 57590,
61819: 57591,
61820: 57592,
61821: 57593,
61822: 57594,
61824: 57595,
61825: 57596,
61826: 57597,
61827: 57598,
61828: 57599,
61829: 57600,
61830: 57601,
61831: 57602,
61832: 57603,
61833: 57604,
61834: 57605,
61835: 57606,
61836: 57607,
61837: 57608,
61838: 57609,
61839: 57610,
61840: 57611,
61841: 57612,
61842: 57613,
61843: 57614,
61844: 57615,
61845: 57616,
61846: 57617,
61847: 57618,
61848: 57619,
61849: 57620,
61850: 57621,
61851: 57622,
61852: 57623,
61853: 57624,
61854: 57625,
61855: 57626,
61856: 57627,
61857: 57628,
61858: 57629,
61859: 57630,
61860: 57631,
61861: 57632,
61862: 57633,
61863: 57634,
61864: 57635,
61865: 57636,
61866: 57637,
61867: 57638,
61868: 57639,
61869: 57640,
61870: 57641,
61871: 57642,
61872: 57643,
61873: 57644,
61874: 57645,
61875: 57646,
61876: 57647,
61877: 57648,
61878: 57649,
61879: 57650,
61880: 57651,
61881: 57652,
61882: 57653,
61883: 57654,
61884: 57655,
61885: 57656,
61886: 57657,
61887: 57658,
61888: 57659,
61889: 57660,
61890: 57661,
61891: 57662,
61892: 57663,
61893: 57664,
61894: 57665,
61895: 57666,
61896: 57667,
61897: 57668,
61898: 57669,
61899: 57670,
61900: 57671,
61901: 57672,
61902: 57673,
61903: 57674,
61904: 57675,
61905: 57676,
61906: 57677,
61907: 57678,
61908: 57679,
61909: 57680,
61910: 57681,
61911: 57682,
61912: 57683,
61913: 57684,
61914: 57685,
61915: 57686,
61916: 57687,
61917: 57688,
61918: 57689,
61919: 57690,
61920: 57691,
61921: 57692,
61922: 57693,
61923: 57694,
61924: 57695,
61925: 57696,
61926: 57697,
61927: 57698,
61928: 57699,
61929: 57700,
61930: 57701,
61931: 57702,
61932: 57703,
61933: 57704,
61934: 57705,
61935: 57706,
61936: 57707,
61937: 57708,
61938: 57709,
61939: 57710,
61940: 57711,
61941: 57712,
61942: 57713,
61943: 57714,
61944: 57715,
61945: 57716,
61946: 57717,
61947: 57718,
61948: 57719,
62016: 57720,
62017: 57721,
62018: 57722,
62019: 57723,
62020: 57724,
62021: 57725,
62022: 57726,
62023: 57727,
62024: 57728,
62025: 57729,
62026: 57730,
62027: 57731,
62028: 57732,
62029: 57733,
62030: 57734,
62031: 57735,
62032: 57736,
62033: 57737,
62034: 57738,
62035: 57739,
62036: 57740,
62037: 57741,
62038: 57742,
62039: 57743,
62040: 57744,
62041: 57745,
62042: 57746,
62043: 57747,
62044: 57748,
62045: 57749,
62046: 57750,
62047: 57751,
62048: 57752,
62049: 57753,
62050: 57754,
62051: 57755,
62052: 57756,
62053: 57757,
62054: 57758,
62055: 57759,
62056: 57760,
62057: 57761,
62058: 57762,
62059: 57763,
62060: 57764,
62061: 57765,
62062: 57766,
62063: 57767,
62064: 57768,
62065: 57769,
62066: 57770,
62067: 57771,
62068: 57772,
62069: 57773,
62070: 57774,
62071: 57775,
62072: 57776,
62073: 57777,
62074: 57778,
62075: 57779,
62076: 57780,
62077: 57781,
62078: 57782,
62080: 57783,
62081: 57784,
62082: 57785,
62083: 57786,
62084: 57787,
62085: 57788,
62086: 57789,
62087: 57790,
62088: 57791,
62089: 57792,
62090: 57793,
62091: 57794,
62092: 57795,
62093: 57796,
62094: 57797,
62095: 57798,
62096: 57799,
62097: 57800,
62098: 57801,
62099: 57802,
62100: 57803,
62101: 57804,
62102: 57805,
62103: 57806,
62104: 57807,
62105: 57808,
62106: 57809,
62107: 57810,
62108: 57811,
62109: 57812,
62110: 57813,
62111: 57814,
62112: 57815,
62113: 57816,
62114: 57817,
62115: 57818,
62116: 57819,
62117: 57820,
62118: 57821,
62119: 57822,
62120: 57823,
62121: 57824,
62122: 57825,
62123: 57826,
62124: 57827,
62125: 57828,
62126: 57829,
62127: 57830,
62128: 57831,
62129: 57832,
62130: 57833,
62131: 57834,
62132: 57835,
62133: 57836,
62134: 57837,
62135: 57838,
62136: 57839,
62137: 57840,
62138: 57841,
62139: 57842,
62140: 57843,
62141: 57844,
62142: 57845,
62143: 57846,
62144: 57847,
62145: 57848,
62146: 57849,
62147: 57850,
62148: 57851,
62149: 57852,
62150: 57853,
62151: 57854,
62152: 57855,
62153: 57856,
62154: 57857,
62155: 57858,
62156: 57859,
62157: 57860,
62158: 57861,
62159: 57862,
62160: 57863,
62161: 57864,
62162: 57865,
62163: 57866,
62164: 57867,
62165: 57868,
62166: 57869,
62167: 57870,
62168: 57871,
62169: 57872,
62170: 57873,
62171: 57874,
62172: 57875,
62173: 57876,
62174: 57877,
62175: 57878,
62176: 57879,
62177: 57880,
62178: 57881,
62179: 57882,
62180: 57883,
62181: 57884,
62182: 57885,
62183: 57886,
62184: 57887,
62185: 57888,
62186: 57889,
62187: 57890,
62188: 57891,
62189: 57892,
62190: 57893,
62191: 57894,
62192: 57895,
62193: 57896,
62194: 57897,
62195: 57898,
62196: 57899,
62197: 57900,
62198: 57901,
62199: 57902,
62200: 57903,
62201: 57904,
62202: 57905,
62203: 57906,
62204: 57907,
62272: 57908,
62273: 57909,
62274: 57910,
62275: 57911,
62276: 57912,
62277: 57913,
62278: 57914,
62279: 57915,
62280: 57916,
62281: 57917,
62282: 57918,
62283: 57919,
62284: 57920,
62285: 57921,
62286: 57922,
62287: 57923,
62288: 57924,
62289: 57925,
62290: 57926,
62291: 57927,
62292: 57928,
62293: 57929,
62294: 57930,
62295: 57931,
62296: 57932,
62297: 57933,
62298: 57934,
62299: 57935,
62300: 57936,
62301: 57937,
62302: 57938,
62303: 57939,
62304: 57940,
62305: 57941,
62306: 57942,
62307: 57943,
62308: 57944,
62309: 57945,
62310: 57946,
62311: 57947,
62312: 57948,
62313: 57949,
62314: 57950,
62315: 57951,
62316: 57952,
62317: 57953,
62318: 57954,
62319: 57955,
62320: 57956,
62321: 57957,
62322: 57958,
62323: 57959,
62324: 57960,
62325: 57961,
62326: 57962,
62327: 57963,
62328: 57964,
62329: 57965,
62330: 57966,
62331: 57967,
62332: 57968,
62333: 57969,
62334: 57970,
62336: 57971,
62337: 57972,
62338: 57973,
62339: 57974,
62340: 57975,
62341: 57976,
62342: 57977,
62343: 57978,
62344: 57979,
62345: 57980,
62346: 57981,
62347: 57982,
62348: 57983,
62349: 57984,
62350: 57985,
62351: 57986,
62352: 57987,
62353: 57988,
62354: 57989,
62355: 57990,
62356: 57991,
62357: 57992,
62358: 57993,
62359: 57994,
62360: 57995,
62361: 57996,
62362: 57997,
62363: 57998,
62364: 57999,
62365: 58e3,
62366: 58001,
62367: 58002,
62368: 58003,
62369: 58004,
62370: 58005,
62371: 58006,
62372: 58007,
62373: 58008,
62374: 58009,
62375: 58010,
62376: 58011,
62377: 58012,
62378: 58013,
62379: 58014,
62380: 58015,
62381: 58016,
62382: 58017,
62383: 58018,
62384: 58019,
62385: 58020,
62386: 58021,
62387: 58022,
62388: 58023,
62389: 58024,
62390: 58025,
62391: 58026,
62392: 58027,
62393: 58028,
62394: 58029,
62395: 58030,
62396: 58031,
62397: 58032,
62398: 58033,
62399: 58034,
62400: 58035,
62401: 58036,
62402: 58037,
62403: 58038,
62404: 58039,
62405: 58040,
62406: 58041,
62407: 58042,
62408: 58043,
62409: 58044,
62410: 58045,
62411: 58046,
62412: 58047,
62413: 58048,
62414: 58049,
62415: 58050,
62416: 58051,
62417: 58052,
62418: 58053,
62419: 58054,
62420: 58055,
62421: 58056,
62422: 58057,
62423: 58058,
62424: 58059,
62425: 58060,
62426: 58061,
62427: 58062,
62428: 58063,
62429: 58064,
62430: 58065,
62431: 58066,
62432: 58067,
62433: 58068,
62434: 58069,
62435: 58070,
62436: 58071,
62437: 58072,
62438: 58073,
62439: 58074,
62440: 58075,
62441: 58076,
62442: 58077,
62443: 58078,
62444: 58079,
62445: 58080,
62446: 58081,
62447: 58082,
62448: 58083,
62449: 58084,
62450: 58085,
62451: 58086,
62452: 58087,
62453: 58088,
62454: 58089,
62455: 58090,
62456: 58091,
62457: 58092,
62458: 58093,
62459: 58094,
62460: 58095,
62528: 58096,
62529: 58097,
62530: 58098,
62531: 58099,
62532: 58100,
62533: 58101,
62534: 58102,
62535: 58103,
62536: 58104,
62537: 58105,
62538: 58106,
62539: 58107,
62540: 58108,
62541: 58109,
62542: 58110,
62543: 58111,
62544: 58112,
62545: 58113,
62546: 58114,
62547: 58115,
62548: 58116,
62549: 58117,
62550: 58118,
62551: 58119,
62552: 58120,
62553: 58121,
62554: 58122,
62555: 58123,
62556: 58124,
62557: 58125,
62558: 58126,
62559: 58127,
62560: 58128,
62561: 58129,
62562: 58130,
62563: 58131,
62564: 58132,
62565: 58133,
62566: 58134,
62567: 58135,
62568: 58136,
62569: 58137,
62570: 58138,
62571: 58139,
62572: 58140,
62573: 58141,
62574: 58142,
62575: 58143,
62576: 58144,
62577: 58145,
62578: 58146,
62579: 58147,
62580: 58148,
62581: 58149,
62582: 58150,
62583: 58151,
62584: 58152,
62585: 58153,
62586: 58154,
62587: 58155,
62588: 58156,
62589: 58157,
62590: 58158,
62592: 58159,
62593: 58160,
62594: 58161,
62595: 58162,
62596: 58163,
62597: 58164,
62598: 58165,
62599: 58166,
62600: 58167,
62601: 58168,
62602: 58169,
62603: 58170,
62604: 58171,
62605: 58172,
62606: 58173,
62607: 58174,
62608: 58175,
62609: 58176,
62610: 58177,
62611: 58178,
62612: 58179,
62613: 58180,
62614: 58181,
62615: 58182,
62616: 58183,
62617: 58184,
62618: 58185,
62619: 58186,
62620: 58187,
62621: 58188,
62622: 58189,
62623: 58190,
62624: 58191,
62625: 58192,
62626: 58193,
62627: 58194,
62628: 58195,
62629: 58196,
62630: 58197,
62631: 58198,
62632: 58199,
62633: 58200,
62634: 58201,
62635: 58202,
62636: 58203,
62637: 58204,
62638: 58205,
62639: 58206,
62640: 58207,
62641: 58208,
62642: 58209,
62643: 58210,
62644: 58211,
62645: 58212,
62646: 58213,
62647: 58214,
62648: 58215,
62649: 58216,
62650: 58217,
62651: 58218,
62652: 58219,
62653: 58220,
62654: 58221,
62655: 58222,
62656: 58223,
62657: 58224,
62658: 58225,
62659: 58226,
62660: 58227,
62661: 58228,
62662: 58229,
62663: 58230,
62664: 58231,
62665: 58232,
62666: 58233,
62667: 58234,
62668: 58235,
62669: 58236,
62670: 58237,
62671: 58238,
62672: 58239,
62673: 58240,
62674: 58241,
62675: 58242,
62676: 58243,
62677: 58244,
62678: 58245,
62679: 58246,
62680: 58247,
62681: 58248,
62682: 58249,
62683: 58250,
62684: 58251,
62685: 58252,
62686: 58253,
62687: 58254,
62688: 58255,
62689: 58256,
62690: 58257,
62691: 58258,
62692: 58259,
62693: 58260,
62694: 58261,
62695: 58262,
62696: 58263,
62697: 58264,
62698: 58265,
62699: 58266,
62700: 58267,
62701: 58268,
62702: 58269,
62703: 58270,
62704: 58271,
62705: 58272,
62706: 58273,
62707: 58274,
62708: 58275,
62709: 58276,
62710: 58277,
62711: 58278,
62712: 58279,
62713: 58280,
62714: 58281,
62715: 58282,
62716: 58283,
62784: 58284,
62785: 58285,
62786: 58286,
62787: 58287,
62788: 58288,
62789: 58289,
62790: 58290,
62791: 58291,
62792: 58292,
62793: 58293,
62794: 58294,
62795: 58295,
62796: 58296,
62797: 58297,
62798: 58298,
62799: 58299,
62800: 58300,
62801: 58301,
62802: 58302,
62803: 58303,
62804: 58304,
62805: 58305,
62806: 58306,
62807: 58307,
62808: 58308,
62809: 58309,
62810: 58310,
62811: 58311,
62812: 58312,
62813: 58313,
62814: 58314,
62815: 58315,
62816: 58316,
62817: 58317,
62818: 58318,
62819: 58319,
62820: 58320,
62821: 58321,
62822: 58322,
62823: 58323,
62824: 58324,
62825: 58325,
62826: 58326,
62827: 58327,
62828: 58328,
62829: 58329,
62830: 58330,
62831: 58331,
62832: 58332,
62833: 58333,
62834: 58334,
62835: 58335,
62836: 58336,
62837: 58337,
62838: 58338,
62839: 58339,
62840: 58340,
62841: 58341,
62842: 58342,
62843: 58343,
62844: 58344,
62845: 58345,
62846: 58346,
62848: 58347,
62849: 58348,
62850: 58349,
62851: 58350,
62852: 58351,
62853: 58352,
62854: 58353,
62855: 58354,
62856: 58355,
62857: 58356,
62858: 58357,
62859: 58358,
62860: 58359,
62861: 58360,
62862: 58361,
62863: 58362,
62864: 58363,
62865: 58364,
62866: 58365,
62867: 58366,
62868: 58367,
62869: 58368,
62870: 58369,
62871: 58370,
62872: 58371,
62873: 58372,
62874: 58373,
62875: 58374,
62876: 58375,
62877: 58376,
62878: 58377,
62879: 58378,
62880: 58379,
62881: 58380,
62882: 58381,
62883: 58382,
62884: 58383,
62885: 58384,
62886: 58385,
62887: 58386,
62888: 58387,
62889: 58388,
62890: 58389,
62891: 58390,
62892: 58391,
62893: 58392,
62894: 58393,
62895: 58394,
62896: 58395,
62897: 58396,
62898: 58397,
62899: 58398,
62900: 58399,
62901: 58400,
62902: 58401,
62903: 58402,
62904: 58403,
62905: 58404,
62906: 58405,
62907: 58406,
62908: 58407,
62909: 58408,
62910: 58409,
62911: 58410,
62912: 58411,
62913: 58412,
62914: 58413,
62915: 58414,
62916: 58415,
62917: 58416,
62918: 58417,
62919: 58418,
62920: 58419,
62921: 58420,
62922: 58421,
62923: 58422,
62924: 58423,
62925: 58424,
62926: 58425,
62927: 58426,
62928: 58427,
62929: 58428,
62930: 58429,
62931: 58430,
62932: 58431,
62933: 58432,
62934: 58433,
62935: 58434,
62936: 58435,
62937: 58436,
62938: 58437,
62939: 58438,
62940: 58439,
62941: 58440,
62942: 58441,
62943: 58442,
62944: 58443,
62945: 58444,
62946: 58445,
62947: 58446,
62948: 58447,
62949: 58448,
62950: 58449,
62951: 58450,
62952: 58451,
62953: 58452,
62954: 58453,
62955: 58454,
62956: 58455,
62957: 58456,
62958: 58457,
62959: 58458,
62960: 58459,
62961: 58460,
62962: 58461,
62963: 58462,
62964: 58463,
62965: 58464,
62966: 58465,
62967: 58466,
62968: 58467,
62969: 58468,
62970: 58469,
62971: 58470,
62972: 58471,
63040: 58472,
63041: 58473,
63042: 58474,
63043: 58475,
63044: 58476,
63045: 58477,
63046: 58478,
63047: 58479,
63048: 58480,
63049: 58481,
63050: 58482,
63051: 58483,
63052: 58484,
63053: 58485,
63054: 58486,
63055: 58487,
63056: 58488,
63057: 58489,
63058: 58490,
63059: 58491,
63060: 58492,
63061: 58493,
63062: 58494,
63063: 58495,
63064: 58496,
63065: 58497,
63066: 58498,
63067: 58499,
63068: 58500,
63069: 58501,
63070: 58502,
63071: 58503,
63072: 58504,
63073: 58505,
63074: 58506,
63075: 58507,
63076: 58508,
63077: 58509,
63078: 58510,
63079: 58511,
63080: 58512,
63081: 58513,
63082: 58514,
63083: 58515,
63084: 58516,
63085: 58517,
63086: 58518,
63087: 58519,
63088: 58520,
63089: 58521,
63090: 58522,
63091: 58523,
63092: 58524,
63093: 58525,
63094: 58526,
63095: 58527,
63096: 58528,
63097: 58529,
63098: 58530,
63099: 58531,
63100: 58532,
63101: 58533,
63102: 58534,
63104: 58535,
63105: 58536,
63106: 58537,
63107: 58538,
63108: 58539,
63109: 58540,
63110: 58541,
63111: 58542,
63112: 58543,
63113: 58544,
63114: 58545,
63115: 58546,
63116: 58547,
63117: 58548,
63118: 58549,
63119: 58550,
63120: 58551,
63121: 58552,
63122: 58553,
63123: 58554,
63124: 58555,
63125: 58556,
63126: 58557,
63127: 58558,
63128: 58559,
63129: 58560,
63130: 58561,
63131: 58562,
63132: 58563,
63133: 58564,
63134: 58565,
63135: 58566,
63136: 58567,
63137: 58568,
63138: 58569,
63139: 58570,
63140: 58571,
63141: 58572,
63142: 58573,
63143: 58574,
63144: 58575,
63145: 58576,
63146: 58577,
63147: 58578,
63148: 58579,
63149: 58580,
63150: 58581,
63151: 58582,
63152: 58583,
63153: 58584,
63154: 58585,
63155: 58586,
63156: 58587,
63157: 58588,
63158: 58589,
63159: 58590,
63160: 58591,
63161: 58592,
63162: 58593,
63163: 58594,
63164: 58595,
63165: 58596,
63166: 58597,
63167: 58598,
63168: 58599,
63169: 58600,
63170: 58601,
63171: 58602,
63172: 58603,
63173: 58604,
63174: 58605,
63175: 58606,
63176: 58607,
63177: 58608,
63178: 58609,
63179: 58610,
63180: 58611,
63181: 58612,
63182: 58613,
63183: 58614,
63184: 58615,
63185: 58616,
63186: 58617,
63187: 58618,
63188: 58619,
63189: 58620,
63190: 58621,
63191: 58622,
63192: 58623,
63193: 58624,
63194: 58625,
63195: 58626,
63196: 58627,
63197: 58628,
63198: 58629,
63199: 58630,
63200: 58631,
63201: 58632,
63202: 58633,
63203: 58634,
63204: 58635,
63205: 58636,
63206: 58637,
63207: 58638,
63208: 58639,
63209: 58640,
63210: 58641,
63211: 58642,
63212: 58643,
63213: 58644,
63214: 58645,
63215: 58646,
63216: 58647,
63217: 58648,
63218: 58649,
63219: 58650,
63220: 58651,
63221: 58652,
63222: 58653,
63223: 58654,
63224: 58655,
63225: 58656,
63226: 58657,
63227: 58658,
63228: 58659,
63296: 58660,
63297: 58661,
63298: 58662,
63299: 58663,
63300: 58664,
63301: 58665,
63302: 58666,
63303: 58667,
63304: 58668,
63305: 58669,
63306: 58670,
63307: 58671,
63308: 58672,
63309: 58673,
63310: 58674,
63311: 58675,
63312: 58676,
63313: 58677,
63314: 58678,
63315: 58679,
63316: 58680,
63317: 58681,
63318: 58682,
63319: 58683,
63320: 58684,
63321: 58685,
63322: 58686,
63323: 58687,
63324: 58688,
63325: 58689,
63326: 58690,
63327: 58691,
63328: 58692,
63329: 58693,
63330: 58694,
63331: 58695,
63332: 58696,
63333: 58697,
63334: 58698,
63335: 58699,
63336: 58700,
63337: 58701,
63338: 58702,
63339: 58703,
63340: 58704,
63341: 58705,
63342: 58706,
63343: 58707,
63344: 58708,
63345: 58709,
63346: 58710,
63347: 58711,
63348: 58712,
63349: 58713,
63350: 58714,
63351: 58715,
63352: 58716,
63353: 58717,
63354: 58718,
63355: 58719,
63356: 58720,
63357: 58721,
63358: 58722,
63360: 58723,
63361: 58724,
63362: 58725,
63363: 58726,
63364: 58727,
63365: 58728,
63366: 58729,
63367: 58730,
63368: 58731,
63369: 58732,
63370: 58733,
63371: 58734,
63372: 58735,
63373: 58736,
63374: 58737,
63375: 58738,
63376: 58739,
63377: 58740,
63378: 58741,
63379: 58742,
63380: 58743,
63381: 58744,
63382: 58745,
63383: 58746,
63384: 58747,
63385: 58748,
63386: 58749,
63387: 58750,
63388: 58751,
63389: 58752,
63390: 58753,
63391: 58754,
63392: 58755,
63393: 58756,
63394: 58757,
63395: 58758,
63396: 58759,
63397: 58760,
63398: 58761,
63399: 58762,
63400: 58763,
63401: 58764,
63402: 58765,
63403: 58766,
63404: 58767,
63405: 58768,
63406: 58769,
63407: 58770,
63408: 58771,
63409: 58772,
63410: 58773,
63411: 58774,
63412: 58775,
63413: 58776,
63414: 58777,
63415: 58778,
63416: 58779,
63417: 58780,
63418: 58781,
63419: 58782,
63420: 58783,
63421: 58784,
63422: 58785,
63423: 58786,
63424: 58787,
63425: 58788,
63426: 58789,
63427: 58790,
63428: 58791,
63429: 58792,
63430: 58793,
63431: 58794,
63432: 58795,
63433: 58796,
63434: 58797,
63435: 58798,
63436: 58799,
63437: 58800,
63438: 58801,
63439: 58802,
63440: 58803,
63441: 58804,
63442: 58805,
63443: 58806,
63444: 58807,
63445: 58808,
63446: 58809,
63447: 58810,
63448: 58811,
63449: 58812,
63450: 58813,
63451: 58814,
63452: 58815,
63453: 58816,
63454: 58817,
63455: 58818,
63456: 58819,
63457: 58820,
63458: 58821,
63459: 58822,
63460: 58823,
63461: 58824,
63462: 58825,
63463: 58826,
63464: 58827,
63465: 58828,
63466: 58829,
63467: 58830,
63468: 58831,
63469: 58832,
63470: 58833,
63471: 58834,
63472: 58835,
63473: 58836,
63474: 58837,
63475: 58838,
63476: 58839,
63477: 58840,
63478: 58841,
63479: 58842,
63480: 58843,
63481: 58844,
63482: 58845,
63483: 58846,
63484: 58847,
63552: 58848,
63553: 58849,
63554: 58850,
63555: 58851,
63556: 58852,
63557: 58853,
63558: 58854,
63559: 58855,
63560: 58856,
63561: 58857,
63562: 58858,
63563: 58859,
63564: 58860,
63565: 58861,
63566: 58862,
63567: 58863,
63568: 58864,
63569: 58865,
63570: 58866,
63571: 58867,
63572: 58868,
63573: 58869,
63574: 58870,
63575: 58871,
63576: 58872,
63577: 58873,
63578: 58874,
63579: 58875,
63580: 58876,
63581: 58877,
63582: 58878,
63583: 58879,
63584: 58880,
63585: 58881,
63586: 58882,
63587: 58883,
63588: 58884,
63589: 58885,
63590: 58886,
63591: 58887,
63592: 58888,
63593: 58889,
63594: 58890,
63595: 58891,
63596: 58892,
63597: 58893,
63598: 58894,
63599: 58895,
63600: 58896,
63601: 58897,
63602: 58898,
63603: 58899,
63604: 58900,
63605: 58901,
63606: 58902,
63607: 58903,
63608: 58904,
63609: 58905,
63610: 58906,
63611: 58907,
63612: 58908,
63613: 58909,
63614: 58910,
63616: 58911,
63617: 58912,
63618: 58913,
63619: 58914,
63620: 58915,
63621: 58916,
63622: 58917,
63623: 58918,
63624: 58919,
63625: 58920,
63626: 58921,
63627: 58922,
63628: 58923,
63629: 58924,
63630: 58925,
63631: 58926,
63632: 58927,
63633: 58928,
63634: 58929,
63635: 58930,
63636: 58931,
63637: 58932,
63638: 58933,
63639: 58934,
63640: 58935,
63641: 58936,
63642: 58937,
63643: 58938,
63644: 58939,
63645: 58940,
63646: 58941,
63647: 58942,
63648: 58943,
63649: 58944,
63650: 58945,
63651: 58946,
63652: 58947,
63653: 58948,
63654: 58949,
63655: 58950,
63656: 58951,
63657: 58952,
63658: 58953,
63659: 58954,
63660: 58955,
63661: 58956,
63662: 58957,
63663: 58958,
63664: 58959,
63665: 58960,
63666: 58961,
63667: 58962,
63668: 58963,
63669: 58964,
63670: 58965,
63671: 58966,
63672: 58967,
63673: 58968,
63674: 58969,
63675: 58970,
63676: 58971,
63677: 58972,
63678: 58973,
63679: 58974,
63680: 58975,
63681: 58976,
63682: 58977,
63683: 58978,
63684: 58979,
63685: 58980,
63686: 58981,
63687: 58982,
63688: 58983,
63689: 58984,
63690: 58985,
63691: 58986,
63692: 58987,
63693: 58988,
63694: 58989,
63695: 58990,
63696: 58991,
63697: 58992,
63698: 58993,
63699: 58994,
63700: 58995,
63701: 58996,
63702: 58997,
63703: 58998,
63704: 58999,
63705: 59e3,
63706: 59001,
63707: 59002,
63708: 59003,
63709: 59004,
63710: 59005,
63711: 59006,
63712: 59007,
63713: 59008,
63714: 59009,
63715: 59010,
63716: 59011,
63717: 59012,
63718: 59013,
63719: 59014,
63720: 59015,
63721: 59016,
63722: 59017,
63723: 59018,
63724: 59019,
63725: 59020,
63726: 59021,
63727: 59022,
63728: 59023,
63729: 59024,
63730: 59025,
63731: 59026,
63732: 59027,
63733: 59028,
63734: 59029,
63735: 59030,
63736: 59031,
63737: 59032,
63738: 59033,
63739: 59034,
63740: 59035,
64064: 8560,
64065: 8561,
64066: 8562,
64067: 8563,
64068: 8564,
64069: 8565,
64070: 8566,
64071: 8567,
64072: 8568,
64073: 8569,
64074: 8544,
64075: 8545,
64076: 8546,
64077: 8547,
64078: 8548,
64079: 8549,
64080: 8550,
64081: 8551,
64082: 8552,
64083: 8553,
64084: 65506,
64085: 65508,
64086: 65287,
64087: 65282,
64088: 12849,
64089: 8470,
64090: 8481,
64091: 8757,
64092: 32394,
64093: 35100,
64094: 37704,
64095: 37512,
64096: 34012,
64097: 20425,
64098: 28859,
64099: 26161,
64100: 26824,
64101: 37625,
64102: 26363,
64103: 24389,
64104: 20008,
64105: 20193,
64106: 20220,
64107: 20224,
64108: 20227,
64109: 20281,
64110: 20310,
64111: 20370,
64112: 20362,
64113: 20378,
64114: 20372,
64115: 20429,
64116: 20544,
64117: 20514,
64118: 20479,
64119: 20510,
64120: 20550,
64121: 20592,
64122: 20546,
64123: 20628,
64124: 20724,
64125: 20696,
64126: 20810,
64128: 20836,
64129: 20893,
64130: 20926,
64131: 20972,
64132: 21013,
64133: 21148,
64134: 21158,
64135: 21184,
64136: 21211,
64137: 21248,
64138: 21255,
64139: 21284,
64140: 21362,
64141: 21395,
64142: 21426,
64143: 21469,
64144: 64014,
64145: 21660,
64146: 21642,
64147: 21673,
64148: 21759,
64149: 21894,
64150: 22361,
64151: 22373,
64152: 22444,
64153: 22472,
64154: 22471,
64155: 64015,
64156: 64016,
64157: 22686,
64158: 22706,
64159: 22795,
64160: 22867,
64161: 22875,
64162: 22877,
64163: 22883,
64164: 22948,
64165: 22970,
64166: 23382,
64167: 23488,
64168: 29999,
64169: 23512,
64170: 23532,
64171: 23582,
64172: 23718,
64173: 23738,
64174: 23797,
64175: 23847,
64176: 23891,
64177: 64017,
64178: 23874,
64179: 23917,
64180: 23992,
64181: 23993,
64182: 24016,
64183: 24353,
64184: 24372,
64185: 24423,
64186: 24503,
64187: 24542,
64188: 24669,
64189: 24709,
64190: 24714,
64191: 24798,
64192: 24789,
64193: 24864,
64194: 24818,
64195: 24849,
64196: 24887,
64197: 24880,
64198: 24984,
64199: 25107,
64200: 25254,
64201: 25589,
64202: 25696,
64203: 25757,
64204: 25806,
64205: 25934,
64206: 26112,
64207: 26133,
64208: 26171,
64209: 26121,
64210: 26158,
64211: 26142,
64212: 26148,
64213: 26213,
64214: 26199,
64215: 26201,
64216: 64018,
64217: 26227,
64218: 26265,
64219: 26272,
64220: 26290,
64221: 26303,
64222: 26362,
64223: 26382,
64224: 63785,
64225: 26470,
64226: 26555,
64227: 26706,
64228: 26560,
64229: 26625,
64230: 26692,
64231: 26831,
64232: 64019,
64233: 26984,
64234: 64020,
64235: 27032,
64236: 27106,
64237: 27184,
64238: 27243,
64239: 27206,
64240: 27251,
64241: 27262,
64242: 27362,
64243: 27364,
64244: 27606,
64245: 27711,
64246: 27740,
64247: 27782,
64248: 27759,
64249: 27866,
64250: 27908,
64251: 28039,
64252: 28015,
64320: 28054,
64321: 28076,
64322: 28111,
64323: 28152,
64324: 28146,
64325: 28156,
64326: 28217,
64327: 28252,
64328: 28199,
64329: 28220,
64330: 28351,
64331: 28552,
64332: 28597,
64333: 28661,
64334: 28677,
64335: 28679,
64336: 28712,
64337: 28805,
64338: 28843,
64339: 28943,
64340: 28932,
64341: 29020,
64342: 28998,
64343: 28999,
64344: 64021,
64345: 29121,
64346: 29182,
64347: 29361,
64348: 29374,
64349: 29476,
64350: 64022,
64351: 29559,
64352: 29629,
64353: 29641,
64354: 29654,
64355: 29667,
64356: 29650,
64357: 29703,
64358: 29685,
64359: 29734,
64360: 29738,
64361: 29737,
64362: 29742,
64363: 29794,
64364: 29833,
64365: 29855,
64366: 29953,
64367: 30063,
64368: 30338,
64369: 30364,
64370: 30366,
64371: 30363,
64372: 30374,
64373: 64023,
64374: 30534,
64375: 21167,
64376: 30753,
64377: 30798,
64378: 30820,
64379: 30842,
64380: 31024,
64381: 64024,
64382: 64025,
64384: 64026,
64385: 31124,
64386: 64027,
64387: 31131,
64388: 31441,
64389: 31463,
64390: 64028,
64391: 31467,
64392: 31646,
64393: 64029,
64394: 32072,
64395: 32092,
64396: 32183,
64397: 32160,
64398: 32214,
64399: 32338,
64400: 32583,
64401: 32673,
64402: 64030,
64403: 33537,
64404: 33634,
64405: 33663,
64406: 33735,
64407: 33782,
64408: 33864,
64409: 33972,
64410: 34131,
64411: 34137,
64412: 34155,
64413: 64031,
64414: 34224,
64415: 64032,
64416: 64033,
64417: 34823,
64418: 35061,
64419: 35346,
64420: 35383,
64421: 35449,
64422: 35495,
64423: 35518,
64424: 35551,
64425: 64034,
64426: 35574,
64427: 35667,
64428: 35711,
64429: 36080,
64430: 36084,
64431: 36114,
64432: 36214,
64433: 64035,
64434: 36559,
64435: 64036,
64436: 64037,
64437: 36967,
64438: 37086,
64439: 64038,
64440: 37141,
64441: 37159,
64442: 37338,
64443: 37335,
64444: 37342,
64445: 37357,
64446: 37358,
64447: 37348,
64448: 37349,
64449: 37382,
64450: 37392,
64451: 37386,
64452: 37434,
64453: 37440,
64454: 37436,
64455: 37454,
64456: 37465,
64457: 37457,
64458: 37433,
64459: 37479,
64460: 37543,
64461: 37495,
64462: 37496,
64463: 37607,
64464: 37591,
64465: 37593,
64466: 37584,
64467: 64039,
64468: 37589,
64469: 37600,
64470: 37587,
64471: 37669,
64472: 37665,
64473: 37627,
64474: 64040,
64475: 37662,
64476: 37631,
64477: 37661,
64478: 37634,
64479: 37744,
64480: 37719,
64481: 37796,
64482: 37830,
64483: 37854,
64484: 37880,
64485: 37937,
64486: 37957,
64487: 37960,
64488: 38290,
64489: 63964,
64490: 64041,
64491: 38557,
64492: 38575,
64493: 38707,
64494: 38715,
64495: 38723,
64496: 38733,
64497: 38735,
64498: 38737,
64499: 38741,
64500: 38999,
64501: 39013,
64502: 64042,
64503: 64043,
64504: 39207,
64505: 64044,
64506: 39326,
64507: 39502,
64508: 39641,
64576: 39644,
64577: 39797,
64578: 39794,
64579: 39823,
64580: 39857,
64581: 39867,
64582: 39936,
64583: 40304,
64584: 40299,
64585: 64045,
64586: 40473,
64587: 40657
};
}
s2u(uint8Array) {
var t = this.s2uTable;
var str = "";
var p = 0;
while (p < uint8Array.length) {
var key = uint8Array[p++];
if (!(key >= 0 && key <= 126 || key >= 161 && key <= 223) && p < uint8Array.length) key = key << 8 | uint8Array[p++];
if (t[key] === void 0) {
console.error("unknown char code " + key + ".");
return str;
}
str += String.fromCharCode(t[key]);
}
return str;
}
};
var DataViewEx = class {
constructor(buffer, littleEndian) {
this.dv = new DataView(buffer);
this.offset = 0;
this.littleEndian = littleEndian !== void 0 ? littleEndian : true;
this.encoder = new CharsetEncoder();
}
getInt8() {
var value = this.dv.getInt8(this.offset);
this.offset += 1;
return value;
}
getInt8Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getInt8());
return a;
}
getUint8() {
var value = this.dv.getUint8(this.offset);
this.offset += 1;
return value;
}
getUint8Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getUint8());
return a;
}
getInt16() {
var value = this.dv.getInt16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
getInt16Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getInt16());
return a;
}
getUint16() {
var value = this.dv.getUint16(this.offset, this.littleEndian);
this.offset += 2;
return value;
}
getUint16Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getUint16());
return a;
}
getInt32() {
var value = this.dv.getInt32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
getInt32Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getInt32());
return a;
}
getUint32() {
var value = this.dv.getUint32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
getUint32Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getUint32());
return a;
}
getFloat32() {
var value = this.dv.getFloat32(this.offset, this.littleEndian);
this.offset += 4;
return value;
}
getFloat32Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getFloat32());
return a;
}
getFloat64() {
var value = this.dv.getFloat64(this.offset, this.littleEndian);
this.offset += 8;
return value;
}
getFloat64Array(size) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getFloat64());
return a;
}
getIndex(type, isUnsigned) {
switch (type) {
case 1: return isUnsigned === true ? this.getUint8() : this.getInt8();
case 2: return isUnsigned === true ? this.getUint16() : this.getInt16();
case 4: return this.getInt32();
default: throw "unknown number type " + type + " exception.";
}
}
getIndexArray(type, size, isUnsigned) {
var a = [];
for (var i = 0; i < size; i++) a.push(this.getIndex(type, isUnsigned));
return a;
}
getChars(size) {
var str = "";
while (size > 0) {
var value = this.getUint8();
size--;
if (value === 0) break;
str += String.fromCharCode(value);
}
while (size > 0) {
this.getUint8();
size--;
}
return str;
}
getSjisStringsAsUnicode(size) {
var a = [];
while (size > 0) {
var value = this.getUint8();
size--;
if (value === 0) break;
a.push(value);
}
while (size > 0) {
this.getUint8();
size--;
}
return this.encoder.s2u(new Uint8Array(a));
}
getUnicodeStrings(size) {
var str = "";
while (size > 0) {
var value = this.getUint16();
size -= 2;
if (value === 0) break;
str += String.fromCharCode(value);
}
while (size > 0) {
this.getUint8();
size--;
}
return str;
}
getTextBuffer() {
var size = this.getUint32();
return this.getUnicodeStrings(size);
}
};
var DataCreationHelper = class {
leftToRightVector3(v) {
v[2] = -v[2];
}
leftToRightQuaternion(q) {
q[0] = -q[0];
q[1] = -q[1];
}
leftToRightEuler(r) {
r[0] = -r[0];
r[1] = -r[1];
}
leftToRightIndexOrder(p) {
var tmp = p[2];
p[2] = p[0];
p[0] = tmp;
}
leftToRightVector3Range(v1, v2) {
var tmp = -v2[2];
v2[2] = -v1[2];
v1[2] = tmp;
}
leftToRightEulerRange(r1, r2) {
var tmp1 = -r2[0];
var tmp2 = -r2[1];
r2[0] = -r1[0];
r2[1] = -r1[1];
r1[0] = tmp1;
r1[1] = tmp2;
}
};
var Parser = class {
constructor() {}
parsePmd(buffer, leftToRight) {
var pmd = {};
var dv = new DataViewEx(buffer);
pmd.metadata = {};
pmd.metadata.format = "pmd";
pmd.metadata.coordinateSystem = "left";
var parseHeader = function() {
var metadata = pmd.metadata;
metadata.magic = dv.getChars(3);
if (metadata.magic !== "Pmd") throw "PMD file magic is not Pmd, but " + metadata.magic;
metadata.version = dv.getFloat32();
metadata.modelName = dv.getSjisStringsAsUnicode(20);
metadata.comment = dv.getSjisStringsAsUnicode(256);
};
var parseVertices = function() {
var parseVertex = function() {
var p = {};
p.position = dv.getFloat32Array(3);
p.normal = dv.getFloat32Array(3);
p.uv = dv.getFloat32Array(2);
p.skinIndices = dv.getUint16Array(2);
p.skinWeights = [dv.getUint8() / 100];
p.skinWeights.push(1 - p.skinWeights[0]);
p.edgeFlag = dv.getUint8();
return p;
};
var metadata = pmd.metadata;
metadata.vertexCount = dv.getUint32();
pmd.vertices = [];
for (var i = 0; i < metadata.vertexCount; i++) pmd.vertices.push(parseVertex());
};
var parseFaces = function() {
var parseFace = function() {
var p = {};
p.indices = dv.getUint16Array(3);
return p;
};
var metadata = pmd.metadata;
metadata.faceCount = dv.getUint32() / 3;
pmd.faces = [];
for (var i = 0; i < metadata.faceCount; i++) pmd.faces.push(parseFace());
};
var parseMaterials = function() {
var parseMaterial = function() {
var p = {};
p.diffuse = dv.getFloat32Array(4);
p.shininess = dv.getFloat32();
p.specular = dv.getFloat32Array(3);
p.ambient = dv.getFloat32Array(3);
p.toonIndex = dv.getInt8();
p.edgeFlag = dv.getUint8();
p.faceCount = dv.getUint32() / 3;
p.fileName = dv.getSjisStringsAsUnicode(20);
return p;
};
var metadata = pmd.metadata;
metadata.materialCount = dv.getUint32();
pmd.materials = [];
for (var i = 0; i < metadata.materialCount; i++) pmd.materials.push(parseMaterial());
};
var parseBones = function() {
var parseBone = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
p.parentIndex = dv.getInt16();
p.tailIndex = dv.getInt16();
p.type = dv.getUint8();
p.ikIndex = dv.getInt16();
p.position = dv.getFloat32Array(3);
return p;
};
var metadata = pmd.metadata;
metadata.boneCount = dv.getUint16();
pmd.bones = [];
for (var i = 0; i < metadata.boneCount; i++) pmd.bones.push(parseBone());
};
var parseIks = function() {
var parseIk = function() {
var p = {};
p.target = dv.getUint16();
p.effector = dv.getUint16();
p.linkCount = dv.getUint8();
p.iteration = dv.getUint16();
p.maxAngle = dv.getFloat32();
p.links = [];
for (var i2 = 0; i2 < p.linkCount; i2++) {
var link = {};
link.index = dv.getUint16();
p.links.push(link);
}
return p;
};
var metadata = pmd.metadata;
metadata.ikCount = dv.getUint16();
pmd.iks = [];
for (var i = 0; i < metadata.ikCount; i++) pmd.iks.push(parseIk());
};
var parseMorphs = function() {
var parseMorph = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
p.elementCount = dv.getUint32();
p.type = dv.getUint8();
p.elements = [];
for (var i2 = 0; i2 < p.elementCount; i2++) p.elements.push({
index: dv.getUint32(),
position: dv.getFloat32Array(3)
});
return p;
};
var metadata = pmd.metadata;
metadata.morphCount = dv.getUint16();
pmd.morphs = [];
for (var i = 0; i < metadata.morphCount; i++) pmd.morphs.push(parseMorph());
};
var parseMorphFrames = function() {
var parseMorphFrame = function() {
var p = {};
p.index = dv.getUint16();
return p;
};
var metadata = pmd.metadata;
metadata.morphFrameCount = dv.getUint8();
pmd.morphFrames = [];
for (var i = 0; i < metadata.morphFrameCount; i++) pmd.morphFrames.push(parseMorphFrame());
};
var parseBoneFrameNames = function() {
var parseBoneFrameName = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(50);
return p;
};
var metadata = pmd.metadata;
metadata.boneFrameNameCount = dv.getUint8();
pmd.boneFrameNames = [];
for (var i = 0; i < metadata.boneFrameNameCount; i++) pmd.boneFrameNames.push(parseBoneFrameName());
};
var parseBoneFrames = function() {
var parseBoneFrame = function() {
var p = {};
p.boneIndex = dv.getInt16();
p.frameIndex = dv.getUint8();
return p;
};
var metadata = pmd.metadata;
metadata.boneFrameCount = dv.getUint32();
pmd.boneFrames = [];
for (var i = 0; i < metadata.boneFrameCount; i++) pmd.boneFrames.push(parseBoneFrame());
};
var parseEnglishHeader = function() {
var metadata = pmd.metadata;
metadata.englishCompatibility = dv.getUint8();
if (metadata.englishCompatibility > 0) {
metadata.englishModelName = dv.getSjisStringsAsUnicode(20);
metadata.englishComment = dv.getSjisStringsAsUnicode(256);
}
};
var parseEnglishBoneNames = function() {
var parseEnglishBoneName = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
return p;
};
var metadata = pmd.metadata;
if (metadata.englishCompatibility === 0) return;
pmd.englishBoneNames = [];
for (var i = 0; i < metadata.boneCount; i++) pmd.englishBoneNames.push(parseEnglishBoneName());
};
var parseEnglishMorphNames = function() {
var parseEnglishMorphName = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
return p;
};
var metadata = pmd.metadata;
if (metadata.englishCompatibility === 0) return;
pmd.englishMorphNames = [];
for (var i = 0; i < metadata.morphCount - 1; i++) pmd.englishMorphNames.push(parseEnglishMorphName());
};
var parseEnglishBoneFrameNames = function() {
var parseEnglishBoneFrameName = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(50);
return p;
};
var metadata = pmd.metadata;
if (metadata.englishCompatibility === 0) return;
pmd.englishBoneFrameNames = [];
for (var i = 0; i < metadata.boneFrameNameCount; i++) pmd.englishBoneFrameNames.push(parseEnglishBoneFrameName());
};
var parseToonTextures = function() {
var parseToonTexture = function() {
var p = {};
p.fileName = dv.getSjisStringsAsUnicode(100);
return p;
};
pmd.toonTextures = [];
for (var i = 0; i < 10; i++) pmd.toonTextures.push(parseToonTexture());
};
var parseRigidBodies = function() {
var parseRigidBody = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
p.boneIndex = dv.getInt16();
p.groupIndex = dv.getUint8();
p.groupTarget = dv.getUint16();
p.shapeType = dv.getUint8();
p.width = dv.getFloat32();
p.height = dv.getFloat32();
p.depth = dv.getFloat32();
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(3);
p.weight = dv.getFloat32();
p.positionDamping = dv.getFloat32();
p.rotationDamping = dv.getFloat32();
p.restitution = dv.getFloat32();
p.friction = dv.getFloat32();
p.type = dv.getUint8();
return p;
};
var metadata = pmd.metadata;
metadata.rigidBodyCount = dv.getUint32();
pmd.rigidBodies = [];
for (var i = 0; i < metadata.rigidBodyCount; i++) pmd.rigidBodies.push(parseRigidBody());
};
var parseConstraints = function() {
var parseConstraint = function() {
var p = {};
p.name = dv.getSjisStringsAsUnicode(20);
p.rigidBodyIndex1 = dv.getUint32();
p.rigidBodyIndex2 = dv.getUint32();
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(3);
p.translationLimitation1 = dv.getFloat32Array(3);
p.translationLimitation2 = dv.getFloat32Array(3);
p.rotationLimitation1 = dv.getFloat32Array(3);
p.rotationLimitation2 = dv.getFloat32Array(3);
p.springPosition = dv.getFloat32Array(3);
p.springRotation = dv.getFloat32Array(3);
return p;
};
var metadata = pmd.metadata;
metadata.constraintCount = dv.getUint32();
pmd.constraints = [];
for (var i = 0; i < metadata.constraintCount; i++) pmd.constraints.push(parseConstraint());
};
parseHeader();
parseVertices();
parseFaces();
parseMaterials();
parseBones();
parseIks();
parseMorphs();
parseMorphFrames();
parseBoneFrameNames();
parseBoneFrames();
parseEnglishHeader();
parseEnglishBoneNames();
parseEnglishMorphNames();
parseEnglishBoneFrameNames();
parseToonTextures();
parseRigidBodies();
parseConstraints();
if (leftToRight === true) this.leftToRightModel(pmd);
return pmd;
}
parsePmx(buffer, leftToRight) {
var pmx = {};
var dv = new DataViewEx(buffer);
pmx.metadata = {};
pmx.metadata.format = "pmx";
pmx.metadata.coordinateSystem = "left";
var parseHeader = function() {
var metadata = pmx.metadata;
metadata.magic = dv.getChars(4);
if (metadata.magic !== "PMX ") throw "PMX file magic is not PMX , but " + metadata.magic;
metadata.version = dv.getFloat32();
if (metadata.version !== 2 && metadata.version !== 2.1) throw "PMX version " + metadata.version + " is not supported.";
metadata.headerSize = dv.getUint8();
metadata.encoding = dv.getUint8();
metadata.additionalUvNum = dv.getUint8();
metadata.vertexIndexSize = dv.getUint8();
metadata.textureIndexSize = dv.getUint8();
metadata.materialIndexSize = dv.getUint8();
metadata.boneIndexSize = dv.getUint8();
metadata.morphIndexSize = dv.getUint8();
metadata.rigidBodyIndexSize = dv.getUint8();
metadata.modelName = dv.getTextBuffer();
metadata.englishModelName = dv.getTextBuffer();
metadata.comment = dv.getTextBuffer();
metadata.englishComment = dv.getTextBuffer();
};
var parseVertices = function() {
var parseVertex = function() {
var p = {};
p.position = dv.getFloat32Array(3);
p.normal = dv.getFloat32Array(3);
p.uv = dv.getFloat32Array(2);
p.auvs = [];
for (var i2 = 0; i2 < pmx.metadata.additionalUvNum; i2++) p.auvs.push(dv.getFloat32Array(4));
p.type = dv.getUint8();
var indexSize = metadata.boneIndexSize;
if (p.type === 0) {
p.skinIndices = dv.getIndexArray(indexSize, 1);
p.skinWeights = [1];
} else if (p.type === 1) {
p.skinIndices = dv.getIndexArray(indexSize, 2);
p.skinWeights = dv.getFloat32Array(1);
p.skinWeights.push(1 - p.skinWeights[0]);
} else if (p.type === 2) {
p.skinIndices = dv.getIndexArray(indexSize, 4);
p.skinWeights = dv.getFloat32Array(4);
} else if (p.type === 3) {
p.skinIndices = dv.getIndexArray(indexSize, 2);
p.skinWeights = dv.getFloat32Array(1);
p.skinWeights.push(1 - p.skinWeights[0]);
p.skinC = dv.getFloat32Array(3);
p.skinR0 = dv.getFloat32Array(3);
p.skinR1 = dv.getFloat32Array(3);
p.type = 1;
} else throw "unsupport bone type " + p.type + " exception.";
p.edgeRatio = dv.getFloat32();
return p;
};
var metadata = pmx.metadata;
metadata.vertexCount = dv.getUint32();
pmx.vertices = [];
for (var i = 0; i < metadata.vertexCount; i++) pmx.vertices.push(parseVertex());
};
var parseFaces = function() {
var parseFace = function() {
var p = {};
p.indices = dv.getIndexArray(metadata.vertexIndexSize, 3, true);
return p;
};
var metadata = pmx.metadata;
metadata.faceCount = dv.getUint32() / 3;
pmx.faces = [];
for (var i = 0; i < metadata.faceCount; i++) pmx.faces.push(parseFace());
};
var parseTextures = function() {
var parseTexture = function() {
return dv.getTextBuffer();
};
var metadata = pmx.metadata;
metadata.textureCount = dv.getUint32();
pmx.textures = [];
for (var i = 0; i < metadata.textureCount; i++) pmx.textures.push(parseTexture());
};
var parseMaterials = function() {
var parseMaterial = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.diffuse = dv.getFloat32Array(4);
p.specular = dv.getFloat32Array(3);
p.shininess = dv.getFloat32();
p.ambient = dv.getFloat32Array(3);
p.flag = dv.getUint8();
p.edgeColor = dv.getFloat32Array(4);
p.edgeSize = dv.getFloat32();
p.textureIndex = dv.getIndex(pmx.metadata.textureIndexSize);
p.envTextureIndex = dv.getIndex(pmx.metadata.textureIndexSize);
p.envFlag = dv.getUint8();
p.toonFlag = dv.getUint8();
if (p.toonFlag === 0) p.toonIndex = dv.getIndex(pmx.metadata.textureIndexSize);
else if (p.toonFlag === 1) p.toonIndex = dv.getInt8();
else throw "unknown toon flag " + p.toonFlag + " exception.";
p.comment = dv.getTextBuffer();
p.faceCount = dv.getUint32() / 3;
return p;
};
var metadata = pmx.metadata;
metadata.materialCount = dv.getUint32();
pmx.materials = [];
for (var i = 0; i < metadata.materialCount; i++) pmx.materials.push(parseMaterial());
};
var parseBones = function() {
var parseBone = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.position = dv.getFloat32Array(3);
p.parentIndex = dv.getIndex(pmx.metadata.boneIndexSize);
p.transformationClass = dv.getUint32();
p.flag = dv.getUint16();
if (p.flag & 1) p.connectIndex = dv.getIndex(pmx.metadata.boneIndexSize);
else p.offsetPosition = dv.getFloat32Array(3);
if (p.flag & 256 || p.flag & 512) {
var grant = {};
grant.isLocal = (p.flag & 128) !== 0 ? true : false;
grant.affectRotation = (p.flag & 256) !== 0 ? true : false;
grant.affectPosition = (p.flag & 512) !== 0 ? true : false;
grant.parentIndex = dv.getIndex(pmx.metadata.boneIndexSize);
grant.ratio = dv.getFloat32();
p.grant = grant;
}
if (p.flag & 1024) p.fixAxis = dv.getFloat32Array(3);
if (p.flag & 2048) {
p.localXVector = dv.getFloat32Array(3);
p.localZVector = dv.getFloat32Array(3);
}
if (p.flag & 8192) p.key = dv.getUint32();
if (p.flag & 32) {
var ik = {};
ik.effector = dv.getIndex(pmx.metadata.boneIndexSize);
ik.target = null;
ik.iteration = dv.getUint32();
ik.maxAngle = dv.getFloat32();
ik.linkCount = dv.getUint32();
ik.links = [];
for (var i2 = 0; i2 < ik.linkCount; i2++) {
var link = {};
link.index = dv.getIndex(pmx.metadata.boneIndexSize);
link.angleLimitation = dv.getUint8();
if (link.angleLimitation === 1) {
link.lowerLimitationAngle = dv.getFloat32Array(3);
link.upperLimitationAngle = dv.getFloat32Array(3);
}
ik.links.push(link);
}
p.ik = ik;
}
return p;
};
var metadata = pmx.metadata;
metadata.boneCount = dv.getUint32();
pmx.bones = [];
for (var i = 0; i < metadata.boneCount; i++) pmx.bones.push(parseBone());
};
var parseMorphs = function() {
var parseMorph = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.panel = dv.getUint8();
p.type = dv.getUint8();
p.elementCount = dv.getUint32();
p.elements = [];
for (var i2 = 0; i2 < p.elementCount; i2++) if (p.type === 0) {
var m = {};
m.index = dv.getIndex(pmx.metadata.morphIndexSize);
m.ratio = dv.getFloat32();
p.elements.push(m);
} else if (p.type === 1) {
var m = {};
m.index = dv.getIndex(pmx.metadata.vertexIndexSize, true);
m.position = dv.getFloat32Array(3);
p.elements.push(m);
} else if (p.type === 2) {
var m = {};
m.index = dv.getIndex(pmx.metadata.boneIndexSize);
m.position = dv.getFloat32Array(3);
m.rotation = dv.getFloat32Array(4);
p.elements.push(m);
} else if (p.type === 3) {
var m = {};
m.index = dv.getIndex(pmx.metadata.vertexIndexSize, true);
m.uv = dv.getFloat32Array(4);
p.elements.push(m);
} else if (p.type === 4);
else if (p.type === 5);
else if (p.type === 6);
else if (p.type === 7);
else if (p.type === 8) {
var m = {};
m.index = dv.getIndex(pmx.metadata.materialIndexSize);
m.type = dv.getUint8();
m.diffuse = dv.getFloat32Array(4);
m.specular = dv.getFloat32Array(3);
m.shininess = dv.getFloat32();
m.ambient = dv.getFloat32Array(3);
m.edgeColor = dv.getFloat32Array(4);
m.edgeSize = dv.getFloat32();
m.textureColor = dv.getFloat32Array(4);
m.sphereTextureColor = dv.getFloat32Array(4);
m.toonColor = dv.getFloat32Array(4);
p.elements.push(m);
}
return p;
};
var metadata = pmx.metadata;
metadata.morphCount = dv.getUint32();
pmx.morphs = [];
for (var i = 0; i < metadata.morphCount; i++) pmx.morphs.push(parseMorph());
};
var parseFrames = function() {
var parseFrame = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.type = dv.getUint8();
p.elementCount = dv.getUint32();
p.elements = [];
for (var i2 = 0; i2 < p.elementCount; i2++) {
var e = {};
e.target = dv.getUint8();
e.index = e.target === 0 ? dv.getIndex(pmx.metadata.boneIndexSize) : dv.getIndex(pmx.metadata.morphIndexSize);
p.elements.push(e);
}
return p;
};
var metadata = pmx.metadata;
metadata.frameCount = dv.getUint32();
pmx.frames = [];
for (var i = 0; i < metadata.frameCount; i++) pmx.frames.push(parseFrame());
};
var parseRigidBodies = function() {
var parseRigidBody = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.boneIndex = dv.getIndex(pmx.metadata.boneIndexSize);
p.groupIndex = dv.getUint8();
p.groupTarget = dv.getUint16();
p.shapeType = dv.getUint8();
p.width = dv.getFloat32();
p.height = dv.getFloat32();
p.depth = dv.getFloat32();
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(3);
p.weight = dv.getFloat32();
p.positionDamping = dv.getFloat32();
p.rotationDamping = dv.getFloat32();
p.restitution = dv.getFloat32();
p.friction = dv.getFloat32();
p.type = dv.getUint8();
return p;
};
var metadata = pmx.metadata;
metadata.rigidBodyCount = dv.getUint32();
pmx.rigidBodies = [];
for (var i = 0; i < metadata.rigidBodyCount; i++) pmx.rigidBodies.push(parseRigidBody());
};
var parseConstraints = function() {
var parseConstraint = function() {
var p = {};
p.name = dv.getTextBuffer();
p.englishName = dv.getTextBuffer();
p.type = dv.getUint8();
p.rigidBodyIndex1 = dv.getIndex(pmx.metadata.rigidBodyIndexSize);
p.rigidBodyIndex2 = dv.getIndex(pmx.metadata.rigidBodyIndexSize);
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(3);
p.translationLimitation1 = dv.getFloat32Array(3);
p.translationLimitation2 = dv.getFloat32Array(3);
p.rotationLimitation1 = dv.getFloat32Array(3);
p.rotationLimitation2 = dv.getFloat32Array(3);
p.springPosition = dv.getFloat32Array(3);
p.springRotation = dv.getFloat32Array(3);
return p;
};
var metadata = pmx.metadata;
metadata.constraintCount = dv.getUint32();
pmx.constraints = [];
for (var i = 0; i < metadata.constraintCount; i++) pmx.constraints.push(parseConstraint());
};
parseHeader();
parseVertices();
parseFaces();
parseTextures();
parseMaterials();
parseBones();
parseMorphs();
parseFrames();
parseRigidBodies();
parseConstraints();
if (leftToRight === true) this.leftToRightModel(pmx);
return pmx;
}
parseVmd(buffer, leftToRight) {
var vmd = {};
var dv = new DataViewEx(buffer);
vmd.metadata = {};
vmd.metadata.coordinateSystem = "left";
var parseHeader = function() {
var metadata = vmd.metadata;
metadata.magic = dv.getChars(30);
if (metadata.magic !== "Vocaloid Motion Data 0002") throw "VMD file magic is not Vocaloid Motion Data 0002, but " + metadata.magic;
metadata.name = dv.getSjisStringsAsUnicode(20);
};
var parseMotions = function() {
var parseMotion = function() {
var p = {};
p.boneName = dv.getSjisStringsAsUnicode(15);
p.frameNum = dv.getUint32();
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(4);
p.interpolation = dv.getUint8Array(64);
return p;
};
var metadata = vmd.metadata;
metadata.motionCount = dv.getUint32();
vmd.motions = [];
for (var i = 0; i < metadata.motionCount; i++) vmd.motions.push(parseMotion());
};
var parseMorphs = function() {
var parseMorph = function() {
var p = {};
p.morphName = dv.getSjisStringsAsUnicode(15);
p.frameNum = dv.getUint32();
p.weight = dv.getFloat32();
return p;
};
var metadata = vmd.metadata;
metadata.morphCount = dv.getUint32();
vmd.morphs = [];
for (var i = 0; i < metadata.morphCount; i++) vmd.morphs.push(parseMorph());
};
var parseCameras = function() {
var parseCamera = function() {
var p = {};
p.frameNum = dv.getUint32();
p.distance = dv.getFloat32();
p.position = dv.getFloat32Array(3);
p.rotation = dv.getFloat32Array(3);
p.interpolation = dv.getUint8Array(24);
p.fov = dv.getUint32();
p.perspective = dv.getUint8();
return p;
};
var metadata = vmd.metadata;
metadata.cameraCount = dv.getUint32();
vmd.cameras = [];
for (var i = 0; i < metadata.cameraCount; i++) vmd.cameras.push(parseCamera());
};
parseHeader();
parseMotions();
parseMorphs();
parseCameras();
if (leftToRight === true) this.leftToRightVmd(vmd);
return vmd;
}
parseVpd(text, leftToRight) {
var vpd = {};
vpd.metadata = {};
vpd.metadata.coordinateSystem = "left";
vpd.bones = [];
var lines = text.replace(/\/\/\w*(\r|\n|\r\n)/g, "").split(/\r|\n|\r\n/);
function throwError() {
throw "the file seems not vpd file.";
}
function checkMagic() {
if (lines[0] !== "Vocaloid Pose Data file") throwError();
}
function parseHeader() {
if (lines.length < 4) throwError();
vpd.metadata.parentFile = lines[2];
vpd.metadata.boneCount = parseInt(lines[3]);
}
function parseBones() {
var boneHeaderPattern = /^\s*(Bone[0-9]+)\s*\{\s*(.*)$/;
var boneVectorPattern = /^\s*(-?[0-9]+\.[0-9]+)\s*,\s*(-?[0-9]+\.[0-9]+)\s*,\s*(-?[0-9]+\.[0-9]+)\s*;/;
var boneQuaternionPattern = /^\s*(-?[0-9]+\.[0-9]+)\s*,\s*(-?[0-9]+\.[0-9]+)\s*,\s*(-?[0-9]+\.[0-9]+)\s*,\s*(-?[0-9]+\.[0-9]+)\s*;/;
var boneFooterPattern = /^\s*}/;
var bones = vpd.bones;
var n = null;
var v = null;
var q = null;
for (var i = 4; i < lines.length; i++) {
var line = lines[i];
var result = line.match(boneHeaderPattern);
if (result !== null) {
if (n !== null) throwError();
n = result[2];
}
result = line.match(boneVectorPattern);
if (result !== null) {
if (v !== null) throwError();
v = [
parseFloat(result[1]),
parseFloat(result[2]),
parseFloat(result[3])
];
}
result = line.match(boneQuaternionPattern);
if (result !== null) {
if (q !== null) throwError();
q = [
parseFloat(result[1]),
parseFloat(result[2]),
parseFloat(result[3]),
parseFloat(result[4])
];
}
result = line.match(boneFooterPattern);
if (result !== null) {
if (n === null || v === null || q === null) throwError();
bones.push({
name: n,
translation: v,
quaternion: q
});
n = null;
v = null;
q = null;
}
}
if (n !== null || v !== null || q !== null) throwError();
}
checkMagic();
parseHeader();
parseBones();
if (leftToRight === true) this.leftToRightVpd(vpd);
return vpd;
}
mergeVmds(vmds) {
var v = {};
v.metadata = {};
v.metadata.name = vmds[0].metadata.name;
v.metadata.coordinateSystem = vmds[0].metadata.coordinateSystem;
v.metadata.motionCount = 0;
v.metadata.morphCount = 0;
v.metadata.cameraCount = 0;
v.motions = [];
v.morphs = [];
v.cameras = [];
for (var i = 0; i < vmds.length; i++) {
var v2 = vmds[i];
v.metadata.motionCount += v2.metadata.motionCount;
v.metadata.morphCount += v2.metadata.morphCount;
v.metadata.cameraCount += v2.metadata.cameraCount;
for (var j = 0; j < v2.metadata.motionCount; j++) v.motions.push(v2.motions[j]);
for (var j = 0; j < v2.metadata.morphCount; j++) v.morphs.push(v2.morphs[j]);
for (var j = 0; j < v2.metadata.cameraCount; j++) v.cameras.push(v2.cameras[j]);
}
return v;
}
leftToRightModel(model) {
if (model.metadata.coordinateSystem === "right") return;
model.metadata.coordinateSystem = "right";
var helper = new DataCreationHelper();
for (var i = 0; i < model.metadata.vertexCount; i++) {
helper.leftToRightVector3(model.vertices[i].position);
helper.leftToRightVector3(model.vertices[i].normal);
}
for (var i = 0; i < model.metadata.faceCount; i++) helper.leftToRightIndexOrder(model.faces[i].indices);
for (var i = 0; i < model.metadata.boneCount; i++) helper.leftToRightVector3(model.bones[i].position);
for (var i = 0; i < model.metadata.morphCount; i++) {
var m = model.morphs[i];
if (model.metadata.format === "pmx" && m.type !== 1) continue;
for (var j = 0; j < m.elements.length; j++) helper.leftToRightVector3(m.elements[j].position);
}
for (var i = 0; i < model.metadata.rigidBodyCount; i++) {
helper.leftToRightVector3(model.rigidBodies[i].position);
helper.leftToRightEuler(model.rigidBodies[i].rotation);
}
for (var i = 0; i < model.metadata.constraintCount; i++) {
helper.leftToRightVector3(model.constraints[i].position);
helper.leftToRightEuler(model.constraints[i].rotation);
helper.leftToRightVector3Range(model.constraints[i].translationLimitation1, model.constraints[i].translationLimitation2);
helper.leftToRightEulerRange(model.constraints[i].rotationLimitation1, model.constraints[i].rotationLimitation2);
}
}
leftToRightVmd(vmd) {
if (vmd.metadata.coordinateSystem === "right") return;
vmd.metadata.coordinateSystem = "right";
var helper = new DataCreationHelper();
for (var i = 0; i < vmd.metadata.motionCount; i++) {
helper.leftToRightVector3(vmd.motions[i].position);
helper.leftToRightQuaternion(vmd.motions[i].rotation);
}
for (var i = 0; i < vmd.metadata.cameraCount; i++) {
helper.leftToRightVector3(vmd.cameras[i].position);
helper.leftToRightEuler(vmd.cameras[i].rotation);
}
}
leftToRightVpd(vpd) {
if (vpd.metadata.coordinateSystem === "right") return;
vpd.metadata.coordinateSystem = "right";
var helper = new DataCreationHelper();
for (var i = 0; i < vpd.bones.length; i++) {
helper.leftToRightVector3(vpd.bones[i].translation);
helper.leftToRightQuaternion(vpd.bones[i].quaternion);
}
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/MMDExporter.js
var __defProp$50 = Object.defineProperty;
var __defNormalProp$50 = (obj, key, value) => key in obj ? __defProp$50(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$50 = (obj, key, value) => {
__defNormalProp$50(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var MMDExporter = class {
constructor() {
__publicField$50(this, "u2sTable");
}
parseVpd(skin, outputShiftJis, useOriginalBones) {
if (skin.isSkinnedMesh !== true) {
console.warn("THREE.MMDExporter: parseVpd() requires SkinnedMesh instance.");
return null;
}
function toStringsFromNumber(num) {
if (Math.abs(num) < 1e-6) num = 0;
let a = num.toString();
if (a.indexOf(".") === -1) a += ".";
a += "000000";
const index = a.indexOf(".");
const d = a.slice(0, index);
const p = a.slice(index + 1, index + 7);
return d + "." + p;
}
function toStringsFromArray(array2) {
const a = [];
for (let i = 0, il = array2.length; i < il; i++) a.push(toStringsFromNumber(array2[i]));
return a.join(",");
}
skin.updateMatrixWorld(true);
const bones = skin.skeleton.bones;
const bones2 = this.getBindBones(skin);
const position = new Vector3();
const quaternion = new Quaternion();
const quaternion2 = new Quaternion();
const matrix = new Matrix4();
const array = [];
array.push("Vocaloid Pose Data file");
array.push("");
array.push((skin.name !== "" ? skin.name.replace(/\s/g, "_") : "skin") + ".osm;");
array.push(bones.length + ";");
array.push("");
for (let i = 0, il = bones.length; i < il; i++) {
const bone = bones[i];
const bone2 = bones2[i];
if (useOriginalBones === true && bone.userData.ik !== void 0 && bone.userData.ik.originalMatrix !== void 0) matrix.fromArray(bone.userData.ik.originalMatrix);
else matrix.copy(bone.matrix);
position.setFromMatrixPosition(matrix);
quaternion.setFromRotationMatrix(matrix);
const pArray = position.sub(bone2.position).toArray();
const qArray = quaternion2.copy(bone2.quaternion).conjugate().multiply(quaternion).toArray();
pArray[2] = -pArray[2];
qArray[0] = -qArray[0];
qArray[1] = -qArray[1];
array.push("Bone" + i + "{" + bone.name);
array.push(" " + toStringsFromArray(pArray) + ";");
array.push(" " + toStringsFromArray(qArray) + ";");
array.push("}");
array.push("");
}
array.push("");
const lines = array.join("\n");
return outputShiftJis === true ? this.unicodeToShiftjis(lines) : lines;
}
unicodeToShiftjis(str) {
if (this.u2sTable === void 0) {
const table = new CharsetEncoder().s2uTable;
this.u2sTable = {};
const keys = Object.keys(table);
for (let i = 0, il = keys.length; i < il; i++) {
let key = keys[i];
const value = table[key];
this.u2sTable[value] = parseInt(key);
}
}
const array = [];
for (let i = 0, il = str.length; i < il; i++) {
const code = str.charCodeAt(i);
const value = this.u2sTable[code];
if (value === void 0) throw "cannot convert charcode 0x" + code.toString(16);
else if (value > 255) {
array.push(value >> 8 & 255);
array.push(value & 255);
} else array.push(value & 255);
}
return new Uint8Array(array);
}
getBindBones(skin) {
const poseSkin = skin.clone();
poseSkin.pose();
return poseSkin.skeleton.bones;
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/STLExporter.js
var __defProp$49 = Object.defineProperty;
var __defNormalProp$49 = (obj, key, value) => key in obj ? __defProp$49(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$49 = (obj, key, value) => {
__defNormalProp$49(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var isMesh = (object) => object.isMesh;
var STLExporter = class {
constructor() {
__publicField$49(this, "binary", false);
__publicField$49(this, "output", "");
__publicField$49(this, "offset", 80);
__publicField$49(this, "objects", []);
__publicField$49(this, "triangles", 0);
__publicField$49(this, "vA", new Vector3());
__publicField$49(this, "vB", new Vector3());
__publicField$49(this, "vC", new Vector3());
__publicField$49(this, "cb", new Vector3());
__publicField$49(this, "ab", new Vector3());
__publicField$49(this, "normal", new Vector3());
}
parse(scene, options) {
this.binary = (options == null ? void 0 : options.binary) !== void 0 ? options == null ? void 0 : options.binary : false;
scene.traverse((object) => {
if (isMesh(object)) {
const geometry = object.geometry;
if (!geometry.isBufferGeometry) throw new Error("THREE.STLExporter: Geometry is not of type THREE.BufferGeometry.");
const index = geometry.index;
const positionAttribute = geometry.getAttribute("position") || null;
if (!positionAttribute) return;
this.triangles += index !== null ? index.count / 3 : positionAttribute.count / 3;
this.objects.push({
object3d: object,
geometry
});
}
});
if (this.binary) {
const bufferLength = this.triangles * 2 + this.triangles * 3 * 4 * 4 + 80 + 4;
const arrayBuffer = new ArrayBuffer(bufferLength);
this.output = new DataView(arrayBuffer);
this.output.setUint32(this.offset, this.triangles, true);
this.offset += 4;
} else {
this.output = "";
this.output += "solid exported\n";
}
for (let i = 0, il = this.objects.length; i < il; i++) {
const object = this.objects[i].object3d;
const geometry = this.objects[i].geometry;
const index = geometry.index;
const positionAttribute = geometry.getAttribute("position");
if (index !== null) for (let j = 0; j < index.count; j += 3) {
const a = index.getX(j + 0);
const b = index.getX(j + 1);
const c = index.getX(j + 2);
this.writeFace(a, b, c, positionAttribute, object);
}
else for (let j = 0; j < positionAttribute.count; j += 3) {
const a = j + 0;
const b = j + 1;
const c = j + 2;
this.writeFace(a, b, c, positionAttribute, object);
}
}
if (!this.binary) this.output += "endsolid exported\n";
return this.output;
}
writeFace(a, b, c, positionAttribute, object) {
this.vA.fromBufferAttribute(positionAttribute, a);
this.vB.fromBufferAttribute(positionAttribute, b);
this.vC.fromBufferAttribute(positionAttribute, c);
if (object.isSkinnedMesh) {
const mesh = object;
if ("applyBoneTransform" in mesh) {
mesh.applyBoneTransform(a, this.vA);
mesh.applyBoneTransform(b, this.vB);
mesh.applyBoneTransform(c, this.vC);
} else {
mesh.boneTransform(a, this.vA);
mesh.boneTransform(b, this.vB);
mesh.boneTransform(c, this.vC);
}
}
this.vA.applyMatrix4(object.matrixWorld);
this.vB.applyMatrix4(object.matrixWorld);
this.vC.applyMatrix4(object.matrixWorld);
this.writeNormal(this.vA, this.vB, this.vC);
this.writeVertex(this.vA);
this.writeVertex(this.vB);
this.writeVertex(this.vC);
if (this.binary && this.output instanceof DataView) {
this.output.setUint16(this.offset, 0, true);
this.offset += 2;
} else {
this.output += " endloop\n";
this.output += " endfacet\n";
}
}
writeNormal(vA, vB, vC) {
this.cb.subVectors(vC, vB);
this.ab.subVectors(vA, vB);
this.cb.cross(this.ab).normalize();
this.normal.copy(this.cb).normalize();
if (this.binary && this.output instanceof DataView) {
this.output.setFloat32(this.offset, this.normal.x, true);
this.offset += 4;
this.output.setFloat32(this.offset, this.normal.y, true);
this.offset += 4;
this.output.setFloat32(this.offset, this.normal.z, true);
this.offset += 4;
} else {
this.output += ` facet normal ${this.normal.x} ${this.normal.y} ${this.normal.z}
`;
this.output += " outer loop\n";
}
}
writeVertex(vertex) {
if (this.binary && this.output instanceof DataView) {
this.output.setFloat32(this.offset, vertex.x, true);
this.offset += 4;
this.output.setFloat32(this.offset, vertex.y, true);
this.offset += 4;
this.output.setFloat32(this.offset, vertex.z, true);
this.offset += 4;
} else this.output += ` vertex ${vertex.x} ${vertex.y} ${vertex.z}
`;
}
};
//#endregion
//#region node_modules/three-stdlib/exporters/OBJExporter.js
var __defProp$48 = Object.defineProperty;
var __defNormalProp$48 = (obj, key, value) => key in obj ? __defProp$48(obj, key, {
enumerable: true,
configurable: true,
writable: true,
value
}) : obj[key] = value;
var __publicField$48 = (obj, key, value) => {
__defNormalProp$48(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var OBJExporter = class {
constructor() {
__publicField$48(this, "output");
__publicField$48(this, "indexVertex");
__publicField$48(this, "indexVertexUvs");
__publicField$48(this, "indexNormals");
__publicField$48(this, "vertex");
__publicField$48(this, "color");
__publicField$48(this, "normal");
__publicField$48(this, "uv");
__publicField$48(this, "face");
this.output = "";
this.indexVertex = 0;
this.indexVertexUvs = 0;
this.indexNormals = 0;
this.vertex = new Vector3();
this.color = new Color();
this.normal = new Vector3();
this.uv = new Vector2();
this.face = [];
}
parse(object) {
object.traverse((child) => {
if (child instanceof Mesh && child.isMesh) this.parseMesh(child);
if (child instanceof Line && child.isLine) this.parseLine(child);
if (child instanceof Points && child.isPoints) this.parsePoints(child);
});
return this.output;
}
parseMesh(mesh) {
let nbVertex = 0;
let nbNormals = 0;
let nbVertexUvs = 0;
const geometry = mesh.geometry;
const normalMatrixWorld = new Matrix3();
if (!geometry.isBufferGeometry) throw new Error("THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.");
const vertices = geometry.getAttribute("position");
const normals = geometry.getAttribute("normal");
const uvs = geometry.getAttribute("uv");
const indices = geometry.getIndex();
this.output += `o ${mesh.name}
`;
if (mesh.material && !Array.isArray(mesh.material) && mesh.material.name) this.output += `usemtl ${mesh.material.name}
`;
if (vertices !== void 0) for (let i = 0, l = vertices.count; i < l; i++, nbVertex++) {
this.vertex.x = vertices.getX(i);
this.vertex.y = vertices.getY(i);
this.vertex.z = vertices.getZ(i);
this.vertex.applyMatrix4(mesh.matrixWorld);
this.output += `v ${this.vertex.x} ${this.vertex.y} ${this.vertex.z}
`;
}
if (uvs !== void 0) for (let i = 0, l = uvs.count; i < l; i++, nbVertexUvs++) {
this.uv.x = uvs.getX(i);
this.uv.y = uvs.getY(i);
this.output += `vt ${this.uv.x} ${this.uv.y}
`;
}
if (normals !== void 0) {
normalMatrixWorld.getNormalMatrix(mesh.matrixWorld);
for (let i = 0, l = normals.count; i < l; i++, nbNormals++) {
this.normal.x = normals.getX(i);
this.normal.y = normals.getY(i);
this.normal.z = normals.getZ(i);
this.normal.applyMatrix3(normalMatrixWorld).normalize();
this.output += `vn ${this.normal.x} ${this.normal.y} ${this.normal.z}
`;
}
}
if (indices !== null) for (let i = 0, l = indices.count; i < l; i += 3) {
for (let m = 0; m < 3; m++) {
const j = indices.getX(i + m) + 1;
this.face[m] = this.indexVertex + j + (normals || uvs ? `/${uvs ? this.indexVertexUvs + j : ""}${normals ? `/${this.indexNormals + j}` : ""}` : "");
}
this.output += `f ${this.face.join(" ")}
`;
}
else for (let i = 0, l = vertices.count; i < l; i += 3) {
for (let m = 0; m < 3; m++) {
const j = i + m + 1;
this.face[m] = this.indexVertex + j + (normals || uvs ? `/${uvs ? this.indexVertexUvs + j : ""}${normals ? `/${this.indexNormals + j}` : ""}` : "");
}
this.output += `f ${this.face.join(" ")}
`;
}
this.indexVertex += nbVertex;
this.indexVertexUvs += nbVertexUvs;
this.indexNormals += nbNormals;
}
parseLine(line) {
let nbVertex = 0;
const geometry = line.geometry;
const type = line.type;
if (geometry.isBufferGeometry) throw new Error("THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.");
const vertices = geometry.getAttribute("position");
this.output += `o ${line.name}
`;
if (vertices !== void 0) for (let i = 0, l = vertices.count; i < l; i++, nbVertex++) {
this.vertex.x = vertices.getX(i);
this.vertex.y = vertices.getY(i);
this.vertex.z = vertices.getZ(i);
this.vertex.applyMatrix4(line.matrixWorld);
this.output += `v ${this.vertex.x} ${this.vertex.y} ${this.vertex.z}
`;
}
if (type === "Line") {
this.output += "l ";
for (let j = 1, l = vertices.count; j <= l; j++) this.output += `${this.indexVertex + j} `;
this.output += "\n";
}
if (type === "LineSegments") for (let j = 1, k = j + 1, l = vertices.count; j < l; j += 2, k = j + 1) this.output += `l ${this.indexVertex + j} ${this.indexVertex + k}
`;
this.indexVertex += nbVertex;
}
parsePoints(points) {
let nbVertex = 0;
const geometry = points.geometry;
if (!geometry.isBufferGeometry) throw new Error("THREE.OBJExporter: Geometry is not of type THREE.BufferGeometry.");
const vertices = geometry.getAttribute("position");
const colors = geometry.getAttribute("color");
this.output += `o ${points.name}
`;
if (vertices !== void 0) for (let i = 0, l = vertices.count; i < l; i++, nbVertex++) {
this.vertex.fromBufferAttribute(vertices, i);
this.vertex.applyMatrix4(points.matrixWorld);
this.output += `v ${this.vertex.x} ${this.vertex.y} ${this.vertex.z}`;
if (colors !== void 0 && colors instanceof BufferAttribute) {
this.color.fromBufferAttribute(colors, i);
this.output += ` ${this.color.r} ${this.color.g} ${this.color.b}`;
}
this.output += "\n";
}
this.output += "p ";
for (let j = 1, l = vertices.count; j <= l; j++) this.output += `${this.indexVertex + j} `;
this.output += "\n";
this.indexVertex += nbVertex;
}
};
//#endregion
//#region node_modules/three-stdlib/environments/RoomEnvironment.js
function RoomEnvironment() {
const scene = new Scene();
const geometry = new BoxGeometry();
geometry.deleteAttribute("uv");
const roomMaterial = new MeshStandardMaterial({ side: 1 });
const boxMaterial = new MeshStandardMaterial();
const mainLight = new PointLight(16777215, 5, 28, 2);
mainLight.position.set(.418, 16.199, .3);
scene.add(mainLight);
const room = new Mesh(geometry, roomMaterial);
room.position.set(-.757, 13.219, .717);
room.scale.set(31.713, 28.305, 28.591);
scene.add(room);
const box1 = new Mesh(geometry, boxMaterial);
box1.position.set(-10.906, 2.009, 1.846);
box1.rotation.set(0, -.195, 0);
box1.scale.set(2.328, 7.905, 4.651);
scene.add(box1);
const box2 = new Mesh(geometry, boxMaterial);
box2.position.set(-5.607, -.754, -.758);
box2.rotation.set(0, .994, 0);
box2.scale.set(1.97, 1.534, 3.955);
scene.add(box2);
const box3 = new Mesh(geometry, boxMaterial);
box3.position.set(6.167, .857, 7.803);
box3.rotation.set(0, .561, 0);
box3.scale.set(3.927, 6.285, 3.687);
scene.add(box3);
const box4 = new Mesh(geometry, boxMaterial);
box4.position.set(-2.017, .018, 6.124);
box4.rotation.set(0, .333, 0);
box4.scale.set(2.002, 4.566, 2.064);
scene.add(box4);
const box5 = new Mesh(geometry, boxMaterial);
box5.position.set(2.291, -.756, -2.621);
box5.rotation.set(0, -.286, 0);
box5.scale.set(1.546, 1.552, 1.496);
scene.add(box5);
const box6 = new Mesh(geometry, boxMaterial);
box6.position.set(-2.193, -.369, -5.547);
box6.rotation.set(0, .516, 0);
box6.scale.set(3.875, 3.487, 2.986);
scene.add(box6);
const light1 = new Mesh(geometry, createAreaLightMaterial(50));
light1.position.set(-16.116, 14.37, 8.208);
light1.scale.set(.1, 2.428, 2.739);
scene.add(light1);
const light2 = new Mesh(geometry, createAreaLightMaterial(50));
light2.position.set(-16.109, 18.021, -8.207);
light2.scale.set(.1, 2.425, 2.751);
scene.add(light2);
const light3 = new Mesh(geometry, createAreaLightMaterial(17));
light3.position.set(14.904, 12.198, -1.832);
light3.scale.set(.15, 4.265, 6.331);
scene.add(light3);
const light4 = new Mesh(geometry, createAreaLightMaterial(43));
light4.position.set(-.462, 8.89, 14.52);
light4.scale.set(4.38, 5.441, .088);
scene.add(light4);
const light5 = new Mesh(geometry, createAreaLightMaterial(20));
light5.position.set(3.235, 11.486, -12.541);
light5.scale.set(2.5, 2, .1);
scene.add(light5);
const light6 = new Mesh(geometry, createAreaLightMaterial(100));
light6.position.set(0, 20, 0);
light6.scale.set(1, .1, 1);
scene.add(light6);
function createAreaLightMaterial(intensity) {
const material = new MeshBasicMaterial();
material.color.setScalar(intensity);
return material;
}
return scene;
}
//#endregion
//#region node_modules/three-stdlib/animation/AnimationClipCreator.js
var AnimationClipCreator = {
CreateRotationAnimation(period, axis = "x") {
const times = [0, period];
return new AnimationClip(null, period, [new NumberKeyframeTrack(".rotation[" + axis + "]", times, [0, 360])]);
},
CreateScaleAxisAnimation(period, axis = "x") {
const times = [0, period];
return new AnimationClip(null, period, [new NumberKeyframeTrack(".scale[" + axis + "]", times, [0, 1])]);
},
CreateShakeAnimation(duration, shakeScale) {
const times = [], values = [], tmp = new Vector3();
for (let i = 0; i < duration * 10; i++) {
times.push(i / 10);
tmp.set(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1).multiply(shakeScale).toArray(values, values.length);
}
return new AnimationClip(null, duration, [new VectorKeyframeTrack(".position", times, values)]);
},
CreatePulsationAnimation(duration, pulseScale) {
const times = [], values = [], tmp = new Vector3();
for (let i = 0; i < duration * 10; i++) {
times.push(i / 10);
const scaleFactor = Math.random() * pulseScale;
tmp.set(scaleFactor, scaleFactor, scaleFactor).toArray(values, values.length);
}
return new AnimationClip(null, duration, [new VectorKeyframeTrack(".scale", times, values)]);
},
CreateVisibilityAnimation(duration) {
return new AnimationClip(null, duration, [new BooleanKeyframeTrack(".visible", [
0,
duration / 2,
duration
], [
true,
false,
true
])]);
},
CreateMaterialColorAnimation(duration, colors) {
const times = [], values = [], timeStep = duration / colors.length;
for (let i = 0; i < colors.length; i++) {
times.push(i * timeStep);
const color = colors[i];
values.push(color.r, color.g, color.b);
}
return new AnimationClip(null, duration, [new ColorKeyframeTrack(".material.color", times, values)]);
}
};
//#endregion
//#region node_modules/three-stdlib/animation/CCDIKSolver.js
var _q$2 = /* @__PURE__ */ new Quaternion();
var _targetPos = /* @__PURE__ */ new Vector3();
var _targetVec = /* @__PURE__ */ new Vector3();
var _effectorPos = /* @__PURE__ */ new Vector3();
var _effectorVec = /* @__PURE__ */ new Vector3();
var _linkPos = /* @__PURE__ */ new Vector3();
var _invLinkQ = /* @__PURE__ */ new Quaternion();
var _linkScale = /* @__PURE__ */ new Vector3();
var _axis = /* @__PURE__ */ new Vector3();
var _vector$3 = /* @__PURE__ */ new Vector3();
var _matrix$1 = /* @__PURE__ */ new Matrix4();
var CCDIKSolver = class {
/**
* @param {THREE.SkinnedMesh} mesh
* @param {Array