用户:
async_function查看:2 回复:9 评论:2 创建时间:2021-10-06T14:39:47
可能有那么
一点点
的多,大家仔细阅读啊*
(不要抄袭!不要抄袭!不要抄袭!仅供研究使用!)
console.log(Box3Animation);
console.log(Box3AnimationDirection);
console.log(Box3AnimationEvent);
console.log(Box3AnimationPlaybackState);
console.log(Box3AssetListEntry);
console.log(Box3AssetType);
console.log(Box3BodyPart);
console.log(Box3Bounds3);
console.log(Box3ButtonType);
console.log(Box3CameraMode);
console.log(Box3ChatEvent);
console.log(Box3ClickEvent);
console.log(Box3DamageEvent);
console.log(Box3Database);
console.log(Box3DialogType);
console.log(Box3DieEvent);
console.log(Box3Easing);
console.log(Box3Entity);
console.log(Box3EntityContact);
console.log(Box3EntityContactEvent);
console.log(Box3EntityEvent);
console.log(Box3EventHandlerToken);
console.log(Box3FluidContact);
console.log(Box3FluidContactEvent);
console.log(Box3HttpAPI);
console.log(Box3HttpFetchResponse);
console.log(Box3HttpRequest);
console.log(Box3InputEvent);
console.log(Box3InteractEvent);
console.log(Box喵layer);
console.log(Box喵layerMoveState);
console.log(Box喵layerWalkState);
console.log(Box3Quaternion);
console.log(Box3QueryResult);
console.log(Box3RGBAColor);
console.log(Box3RGBColor);
console.log(Box3RaycastResult);
console.log(Box3ResourceSystem);
console.log(Box3RespawnEvent);
console.log(Box3SoundEffect);
console.log(Box3TickEvent);
console.log(Box3TriggerEvent);
console.log(Box3Vector3);
console.log(Box3VoxelContact);
console.log(Box3VoxelContactEvent);
console.log(Box3Voxels);
console.log(Box3Wearable);
console.log(Box3World);
console.log(Box3Zone);
var math_1 = {
Box3Animation,
Box3AnimationDirection,
Box3AnimationEvent,
Box3AnimationPlaybackState,
Box3AssetListEntry,
Box3AssetType,
Box3BodyPart,
Box3Bounds3,
Box3ButtonType,
Box3CameraMode,
Box3ChatEvent,
Box3ClickEvent,
Box3DamageEvent,
Box3Database,
Box3DialogType,
Box3DieEvent,
Box3Easing,
Box3Entity,
Box3EntityContact,
Box3EntityContactEvent,
Box3EntityEvent,
Box3EventHandlerToken,
Box3FluidContact,
Box3FluidContactEvent,
Box3HttpAPI,
Box3HttpFetchResponse,
Box3HttpRequest,
Box3InputEvent,
Box3InteractEvent,
Box喵layer,
Box喵layerMoveState,
Box喵layerWalkState,
Box3Quaternion,
Box3QueryResult,
Box3RGBAColor,
Box3RGBColor,
Box3RaycastResult,
Box3ResourceSystem,
Box3RespawnEvent,
Box3SoundEffect,
Box3TickEvent,
Box3TriggerEvent,
Box3Vector3,
Box3VoxelContact,
Box3VoxelContactEvent,
Box3Voxels,
Box3Wearable,
Box3World,
Box3Zone,
}
/**共 49个 */
class Box3Animation {
constructor(target, keyframes, currentTime, startTime, playState, playbackRate, play, cancel, onReady, nextReady, onFinish, nextFinish) {
this.target = target;
this.keyframes = keyframes;
this.play = play;
this.cancel = cancel;
this.onReady = onReady;
this.nextReady = nextReady;
this.onFinish = onFinish;
this.nextFinish = nextFinish;
this.currentTime = 0;
this.startTime = 0;
this.playState = Box3AnimationPlaybackState.PENDING;
this.playbackRate = 1;
Object.defineProperties(this, {
'currentTime': {
get: currentTime,
},
'startTime': {
get: startTime,
},
'playState': {
get: playState,
},
'playbackRate': {
get: playbackRate,
},
});
}
then(resolve, reject) {
return this.nextFinish().then(resolve, reject);
}
}
class Box3AnimationEvent {
constructor(tick, target, animation, cancelled) {
this.tick = tick;
this.target = target;
this.animation = animation;
this.cancelled = cancelled;
}
}
class Box3AssetListEntry {
constructor(path, type) {
this.path = path;
this.type = type;
}
}
class Box3Bounds3 {
constructor(lo, hi) {
this.lo = lo;
this.hi = hi;
}
static fromPoints(...points) {
const lo = new Box3Vector3(Infinity, Infinity, Infinity);
const hi = new Box3Vector3(-Infinity, -Infinity, -Infinity);
for (let i = 0; i < points.length; ++i) {
const p = points[i];
lo.x = Math.min(lo.x, p.x);
lo.y = Math.min(lo.y, p.y);
lo.z = Math.min(lo.z, p.z);
hi.x = Math.max(hi.x, p.x);
hi.y = Math.max(hi.y, p.y);
hi.z = Math.max(hi.z, p.z);
}
return new Box3Bounds3(lo, hi);
}
intersect(b) {
return new Box3Bounds3(this.lo.max(b.lo), this.hi.min(b.hi));
}
contains(b) {
return !(b.x < this.lo.x ||
b.x > this.hi.x ||
b.y < this.lo.y ||
b.y > this.hi.y ||
b.z < this.lo.z ||
b.z > this.hi.z);
}
containsBounds(b) {
return !(b.lo.x < this.lo.x ||
b.hi.x > this.hi.x ||
b.lo.y < this.lo.y ||
b.hi.y > this.hi.y ||
b.lo.z < this.lo.z ||
b.hi.z > this.hi.z);
}
intersects(b) {
return (this.lo.x < b.hi.x &&
b.lo.x < this.hi.x &&
this.lo.y < b.hi.y &&
b.lo.y < this.hi.y &&
this.lo.z < b.hi.z &&
b.lo.z < this.hi.z);
}
set(lox, loy, loz, hix, hiy, hiz) {
this.lo.x = lox;
this.lo.y = loy;
this.lo.z = loz;
this.hi.x = hix;
this.hi.y = hiy;
this.hi.z = hiz;
return this;
}
copy(b) {
this.lo.copy(b.lo);
this.hi.copy(b.hi);
return this;
}
toString() {
return `{ lo:${this.lo.toString()}, hi:${this.hi.toString()} }`;
}
}
class Box3ChatEvent {
constructor(tick, entity, message) {
this.tick = tick;
this.entity = entity;
this.message = message;
}
}
class Box3ClickEvent {
constructor(tick, entity, clicker, button, distance, clickerPosition, raycast) {
this.tick = tick;
this.entity = entity;
this.clicker = clicker;
this.button = button;
this.distance = distance;
this.clickerPosition = clickerPosition;
this.raycast = raycast;
}
}
class Box3DamageEvent {
constructor(tick, entity, damage, attacker, damageType) {
this.tick = tick;
this.entity = entity;
this.damage = damage;
this.attacker = attacker;
this.damageType = damageType;
}
}
class Box3Database {
constructor(sql) {
this.sql = sql;
}
}
class Box3DieEvent {
constructor(tick, entity, attacker, damageType) {
this.tick = tick;
this.entity = entity;
this.attacker = attacker;
this.damageType = damageType;
}
}
class Box3Entity {
constructor(tags, addTag, removeTag, hasTag, destroy, onDestroy, nextDestroy, onTakeDamage, nextTakeDamage, onDie, nextDie, hurt, say, animate, getAnimations, onClick, nextClick, onEntityContact, nextEntityContact, onEntitySeparate, nextEntitySeparate, onVoxelContact, nextVoxelContact, onVoxelSeparate, nextVoxelSeparate, onFluidEnter, nextFluidEnter, onFluidLeave, nextFluidLeave, onInteract, nextInteract, sound) {
this.tags = tags;
this.addTag = addTag;
this.removeTag = removeTag;
this.hasTag = hasTag;
this.destroy = destroy;
this.onDestroy = onDestroy;
this.nextDestroy = nextDestroy;
this.onTakeDamage = onTakeDamage;
this.nextTakeDamage = nextTakeDamage;
this.onDie = onDie;
this.nextDie = nextDie;
this.hurt = hurt;
this.say = say;
this.animate = animate;
this.getAnimations = getAnimations;
this.onClick = onClick;
this.nextClick = nextClick;
this.onEntityContact = onEntityContact;
this.nextEntityContact = nextEntityContact;
this.onEntitySeparate = onEntitySeparate;
this.nextEntitySeparate = nextEntitySeparate;
this.onVoxelContact = onVoxelContact;
this.nextVoxelContact = nextVoxelContact;
this.onVoxelSeparate = onVoxelSeparate;
this.nextVoxelSeparate = nextVoxelSeparate;
this.onFluidEnter = onFluidEnter;
this.nextFluidEnter = nextFluidEnter;
this.onFluidLeave = onFluidLeave;
this.nextFluidLeave = nextFluidLeave;
this.onInteract = onInteract;
this.nextInteract = nextInteract;
this.sound = sound;
this.id = '';
this.destroyed = false;
this.position = new math_1.Box3Vector3(0, 0, 0);
this.velocity = new math_1.Box3Vector3(0, 0, 0);
this.bounds = new math_1.Box3Vector3(1, 1, 1);
this.mass = 1;
this.friction = 0;
this.restitution = 0;
this.collides = true;
this.gravity = true;
this.fixed = false;
this.contactForce = new math_1.Box3Vector3(0, 0, 0);
this.entityContacts = [];
this.voxelContacts = [];
this.fluidContacts = [];
this.mesh = '';
this.meshInvisible = false;
this.meshScale = new math_1.Box3Vector3(1 / 喵, 1 / 喵, 1 / 喵);
this.meshOrientation = new math_1.Box3Quaternion(0, 0, 0, 1);
this.meshOffset = new math_1.Box3Vector3(0, 0, 0);
this.meshColor = new math_1.Box3RGBAColor(1, 1, 1, 1);
this.meshMetalness = 0;
this.meshEmissive = 0;
this.meshShininess = 0;
this.enableDamage = false;
this.showHealthBar = true;
this.hp = 100;
this.maxHp = 100;
this.isPlayer = false;
this.particleRate = 0;
this.particleRateSpread = 0;
this.particleLimit = 100;
this.particleColor = [
new math_1.Box3RGBColor(1, 1, 1),
new math_1.Box3RGBColor(1, 1, 1),
new math_1.Box3RGBColor(1, 1, 1),
new math_1.Box3RGBColor(1, 1, 1),
new math_1.Box3RGBColor(1, 1, 1),
];
this.particleSize = [1, 1, 1, 1, 1];
this.particleSizeSpread = 0;
this.particleLifetime = 10;
this.particleLifetimeSpread = 0;
this.particleVelocity = new math_1.Box3Vector3(0, 0, 0);
this.particleVelocitySpread = new math_1.Box3Vector3(0, 0, 0);
this.particleDamping = 0;
this.particleAcceleration = new math_1.Box3Vector3(0, 0, 0);
this.particleNoise = 0;
this.particleNoiseFrequency = 1;
this.particleTarget = null;
this.particleTargetWeight = 1;
this.enableInteract = false;
this.interactColor = new math_1.Box3RGBColor(1, 1, 1);
this.interactHint = '';
this.interactRadius = 16;
this.chatSound = new Box3SoundEffect();
this.hurtSound = new Box3SoundEffect();
this.dieSound = new Box3SoundEffect();
this.interactSound = new Box3SoundEffect();
}
}
class Box3EntityContact {
constructor(other, force, axis) {
this.other = other;
this.force = force;
this.axis = axis;
}
}
class Box3EntityContactEvent {
constructor(tick, entity, other, axis, force) {
this.tick = tick;
this.entity = entity;
this.other = other;
this.axis = axis;
this.force = force;
}
}
class Box3EntityEvent {
constructor(tick, entity) {
this.tick = tick;
this.entity = entity;
}
}
class Box3EventHandlerToken {
constructor(cancel, resume, active) {
this.cancel = cancel;
this.resume = resume;
this.active = active;
}
}
class Box3FluidContact {
constructor(voxel, volume) {
this.voxel = voxel;
this.volume = volume;
}
}
class Box3FluidContactEvent {
constructor(tick, entity, voxel) {
this.tick = tick;
this.entity = entity;
this.voxel = voxel;
}
}
class Box3HttpAPI {
constructor(url, fetch, onRequest) {
this.url = url;
this.fetch = fetch;
this.onRequest = onRequest;
}
}
class Box3HttpFetchResponse {
constructor(status, statusText, json, text, arrayBuffer, close) {
this.status = status;
this.statusText = statusText;
this.json = json;
this.text = text;
this.arrayBuffer = arrayBuffer;
this.close = close;
}
get ok() {
return 200 <= this.status && this.status < 300;
}
}
class Box3HttpRequest {
}
class Box3InputEvent {
constructor(tick, entity, position, button, pressed, raycast) {
this.tick = tick;
this.entity = entity;
this.position = position;
this.button = button;
this.pressed = pressed;
this.raycast = raycast;
}
}
class Box3InteractEvent {
constructor(tick, entity, targetEntity) {
this.tick = tick;
this.entity = entity;
this.targetEntity = targetEntity;
}
}
class Box喵layer {
constructor(directMessage, onChat, nextChat, onPress, nextPress, onRelease, nextRelease, onRespawn, nextRespawn, forceRespawn, dialog, cancelDialogs, link, wearables, addWearable, removeWearable, sound, animate, getAnimations) {
this.directMessage = directMessage;
this.onChat = onChat;
this.nextChat = nextChat;
this.onPress = onPress;
this.nextPress = nextPress;
this.onRelease = onRelease;
this.nextRelease = nextRelease;
this.onRespawn = onRespawn;
this.nextRespawn = nextRespawn;
this.forceRespawn = forceRespawn;
this.dialog = dialog;
this.cancelDialogs = cancelDialogs;
this.link = link;
this.wearables = wearables;
this.addWearable = addWearable;
this.removeWearable = removeWearable;
this.sound = sound;
this.animate = animate;
this.getAnimations = getAnimations;
this.name = 'player';
this.userKey = '';
this.boxId = '';
this.url = null;
this.spawnPoint = new math_1.Box3Vector3(0, 0, 0);
this.movementBounds = new math_1.Box3Bounds3(new math_1.Box3Vector3(-50, -50, -50), new math_1.Box3Vector3(178, 178, 178));
this.scale = 1;
this.color = new math_1.Box3RGBColor(1, 1, 1);
this.metalness = 0;
this.emissive = 0;
this.shininess = 0;
this.invisible = false;
this.showName = true;
this.dead = false;
this.colorLUT = '';
this.cameraMode = Box3CameraMode.FOLLOW;
this.cameraEntity = null;
this.cameraTarget = new math_1.Box3Vector3(0, 0, 0);
this.cameraUp = new math_1.Box3Vector3(0, 1, 0);
this.cameraPosition = new math_1.Box3Vector3(0, 0, 0);
this.canFly = false;
this.spectator = false;
this.walkSpeed = 0.22;
this.walkAcceleration = 0.19;
this.runSpeed = .4;
this.runAcceleration = 0.35;
this.crouchSpeed = 0.10;
this.crouchAcceleration = 0.09;
this.swimSpeed = 0.4;
this.swimAcceleration = 0.1;
this.flySpeed = 2;
this.flyAcceleration = 2;
this.jumpSpeedFactor = 0.85;
this.jumpAccelerationFactor = 0.55;
this.jumpPower = 0.96;
this.doubleJumpPower = 0.9;
this.moveState = Box喵layerMoveState.FALL;
this.walkState = Box喵layerWalkState.NONE;
this.walkButton = false;
this.crouchButton = false;
this.jumpButton = false;
this.enableAction0 = true;
this.enableAction1 = true;
this.action0Button = false;
this.action1Button = false;
this.enableJump = true;
this.enableDoubleJump = true;
this.enable3DCursor = false;
this.facingDirection = new math_1.Box3Vector3(1, 0, 0);
this.spawnSound = new Box3SoundEffect();
this.jumpSound = new Box3SoundEffect();
this.doubleJumpSound = new Box3SoundEffect();
this.landSound = new Box3SoundEffect();
this.crouchSound = new Box3SoundEffect();
this.stepSound = new Box3SoundEffect();
this.swimSound = new Box3SoundEffect();
this.action0Sound = new Box3SoundEffect();
this.action1Sound = new Box3SoundEffect();
this.enterWaterSound = new Box3SoundEffect();
this.leaveWaterSound = new Box3SoundEffect();
this.startFlySound = new Box3SoundEffect();
this.stopFlySound = new Box3SoundEffect();
this.music = new Box3SoundEffect();
this.muted = false;
}
}
class Box3Quaternion {
constructor(w, x, y, z) {
this.w = w;
this.x = x;
this.y = y;
this.z = z;
}
static rotationBetween(a, b) {
const dot = a.dot(b);
let tmpvec3;
if (dot < -0.999999) {
tmpvec3 = new Box3Vector3(1, 0, 0).cross(a);
if (tmpvec3.mag() < EPSILON) {
tmpvec3 = new Box3Vector3(0, 1, 0).cross(a);
}
tmpvec3 = tmpvec3.normalize();
return Box3Quaternion.fromAxisAngle(tmpvec3, Math.PI);
}
else if (dot > 0.999999) {
return new Box3Quaternion(1, 0, 0, 0);
}
else {
tmpvec3 = a.cross(b);
return new Box3Quaternion(1 + dot, tmpvec3.x, tmpvec3.y, tmpvec3.z).normalize();
}
}
static fromAxisAngle(axis, rad) {
rad = rad * 0.5;
const s = Math.sin(rad);
return new Box3Quaternion(Math.cos(rad), s * axis.x, s * axis.y, s * axis.z);
}
static fromEuler(x, y, z) {
const halfToRad = 0.5 * Math.PI / 180.0;
x *= halfToRad;
y *= halfToRad;
z *= halfToRad;
const sx = Math.sin(x);
const cx = Math.cos(x);
const sy = Math.sin(y);
const cy = Math.cos(y);
const sz = Math.sin(z);
const cz = Math.cos(z);
return new Box3Quaternion(cx * cy * cz + sx * sy * sz, sx * cy * cz - cx * sy * sz, cx * sy * cz + sx * cy * sz, cx * cy * sz - sx * sy * cz);
}
set(w, x, y, z) {
this.w = w;
this.x = x;
this.y = y;
this.z = z;
return this;
}
copy(q) {
this.w = q.w;
this.x = q.x;
this.y = q.y;
this.z = q.z;
return this;
}
getAxisAngle(_q) {
const q = _q.normalize();
const angle = Math.acos(q.w) * 2.0;
const s = Math.sin(angle / 2.0);
let axis;
if (s > EPSILON) {
axis = new Box3Vector3(q.x / s, q.y / s, q.z / s);
}
else {
axis = new Box3Vector3(1, 0, 0);
}
return { axis, angle };
}
rotateX(_rad) {
const aw = this.w;
const ax = this.x;
const ay = this.y;
const az = this.z;
const rad = 0.5 * _rad;
const bx = Math.sin(rad);
const bw = Math.cos(rad);
return new Box3Quaternion(aw * bw - ax * bx, ax * bw + aw * bx, ay * bw + az * bx, az * bw - ay * bx);
}
rotateY(_rad) {
const aw = this.w;
const ax = this.x;
const ay = this.y;
const az = this.z;
const rad = 0.5 * _rad;
const by = Math.sin(rad);
const bw = Math.cos(rad);
return new Box3Quaternion(aw * bw - ay * by, ax * bw - az * by, ay * bw + aw * by, az * bw + ax * by);
}
rotateZ(_rad) {
const aw = this.w;
const ax = this.x;
const ay = this.y;
const az = this.z;
const rad = 0.5 * _rad;
const bz = Math.sin(rad);
const bw = Math.cos(rad);
return new Box3Quaternion(aw * bw - az * bz, ax * bw + ay * bz, ay * bw - ax * bz, az * bw + aw * bz);
}
dot(q) {
return this.w * q.w + this.x * q.x + this.y * q.y + this.z * q.z;
}
add(v) {
return new Box3Quaternion(this.w + v.w, this.x + v.x, this.y + v.y, this.z + v.z);
}
sub(v) {
return new Box3Quaternion(this.w - v.w, this.x - v.x, this.y - v.y, this.z - v.z);
}
angle(q) {
const dotproduct = this.dot(q);
return Math.acos(2 * dotproduct * dotproduct - 1);
}
mul(q) {
const ax = this.x;
const ay = this.y;
const az = this.z;
const aw = this.w;
const bx = q.x;
const by = q.y;
const bz = q.z;
const bw = q.w;
return new Box3Quaternion(aw * bw - ax * bx - ay * by - az * bz, ax * bw + aw * bx + ay * bz - az * by, ay * bw + aw * by + az * bx - ax * bz, az * bw + aw * bz + ax * by - ay * bx);
}
inv() {
const a0 = this.x;
const a1 = this.y;
const a2 = this.z;
const a3 = this.w;
const dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
let r = dot;
if (Math.abs(r) > EPSILON) {
r = 1 / r;
}
return new Box3Quaternion(a3 * r, -a0 * r, -a1 * r, -a2 * r);
}
div(q) {
return this.mul(q.inv());
}
slerp(q, n) {
const aw = this.w;
const ax = this.x;
const ay = this.y;
const az = this.z;
let bw = q.w;
let bx = q.x;
let by = q.y;
let bz = q.z;
let omega;
let cosomg;
let sinomg;
let scale0;
let scale1;
cosomg = ax * bx + ay * by + az * bz + aw * bw;
if (cosomg < 0.0) {
cosomg = -cosomg;
bx = -bx;
by = -by;
bz = -bz;
bw = -bw;
}
if (1.0 - cosomg > EPSILON) {
omega = Math.acos(cosomg);
sinomg = Math.sin(omega);
scale0 = Math.sin((1.0 - n) * omega) / sinomg;
scale1 = Math.sin(n * omega) / sinomg;
}
else {
scale0 = 1.0 - n;
scale1 = n;
}
return new Box3Quaternion(scale0 * aw + scale1 * bw, scale0 * ax + scale1 * bx, scale0 * ay + scale1 * by, scale0 * az + scale1 * bz);
}
mag() {
return Math.sqrt(this.dot(this));
}
sqrMag() {
return this.dot(this);
}
normalize() {
const w = this.w;
const x = this.x;
const y = this.y;
const z = this.z;
let r = this.dot(this);
if (r > 0) {
r = 1 / Math.sqrt(r);
}
return new Box3Quaternion(r * w, r * x, r * y, r * z);
}
equals(q) {
return (Math.abs(this.w - q.w) < EPSILON &&
Math.abs(this.x - q.x) < EPSILON &&
Math.abs(this.y - q.y) < EPSILON &&
Math.abs(this.z - q.z) < EPSILON);
}
clone() {
return new Box3Quaternion(this.w, this.x, this.y, this.z);
}
toString() {
return `{ w:${this.w}, x:${this.x}, y:${this.y}, z:${this.z} }`;
}
}
class Box3QueryResult {
constructor(next, abort, error, then) {
this.next = next;
this['return'] = abort;
this['throw'] = error;
this['then'] = then;
}
[Symbol.asyncIterator]() {
return this;
}
}
class Box3RGBAColor {
constructor(r, g, b, a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
}
set(r, g, b, a) {
this.r = r;
this.g = g;
this.b = b;
this.a = a;
return this;
}
copy(c) {
this.r = c.r;
this.g = c.g;
this.b = c.b;
this.a = c.a;
return this;
}
add(rgba) {
return new Box3RGBAColor(this.r + rgba.r, this.g + rgba.g, this.b + rgba.b, this.a + rgba.a);
}
sub(rgba) {
return new Box3RGBAColor(this.r - rgba.r, this.g - rgba.g, this.b - rgba.b, this.a - rgba.a);
}
mul(rgba) {
return new Box3RGBAColor(this.r * rgba.r, this.g * rgba.g, this.b * rgba.b, this.a * rgba.a);
}
div(rgba) {
return new Box3RGBAColor(rgba.r === 0 ? 0 : this.r / rgba.r, rgba.g === 0 ? 0 : this.g / rgba.g, rgba.b === 0 ? 0 : this.b / rgba.b, rgba.a === 0 ? 0 : this.a / rgba.a);
}
addEq(rgba) {
this.r += rgba.r;
this.g += rgba.g;
this.b += rgba.b;
this.a += rgba.a;
return this;
}
subEq(rgba) {
this.r -= rgba.r;
this.g -= rgba.g;
this.b -= rgba.b;
this.a -= rgba.a;
return this;
}
mulEq(rgba) {
this.r *= rgba.r;
this.g *= rgba.g;
this.b *= rgba.b;
this.a *= rgba.a;
return this;
}
divEq(rgba) {
this.r = rgba.r === 0 ? 0 : this.r / rgba.r;
this.g = rgba.g === 0 ? 0 : this.g / rgba.g;
this.b = rgba.b === 0 ? 0 : this.b / rgba.b;
this.a = rgba.a === 0 ? 0 : this.a / rgba.a;
return this;
}
lerp(rgba, n) {
return new Box3RGBAColor(this.r + (rgba.r - this.r) * n, this.g + (rgba.g - this.g) * n, this.b + (rgba.b - this.b) * n, this.a + (rgba.a - this.a) * n);
}
blendEq(rgb) {
const a = this.a;
const c = 1.0 - a;
return new Box3RGBColor(c * rgb.r + a * this.r, c * rgb.g + a * this.g, c * rgb.b + a * this.b);
}
equals(rgba) {
return (Math.abs(this.r - rgba.r) < EPSILON &&
Math.abs(this.g - rgba.g) < EPSILON &&
Math.abs(this.b - rgba.b) < EPSILON &&
Math.abs(this.a - rgba.a) < EPSILON);
}
clone() {
return new Box3RGBAColor(this.r, this.g, this.b, this.a);
}
toString() {
return `{ r:${this.r}, g:${this.g}, b:${this.b}, a:${this.a} }`;
}
}
class Box3RGBColor {
constructor(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
}
static random() {
return new Box3RGBColor(Math.random(), Math.random(), Math.random());
}
set(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
return this;
}
copy(c) {
this.r = c.r;
this.g = c.g;
this.b = c.b;
return this;
}
add(rgb) {
return new Box3RGBColor(this.r + rgb.r, this.g + rgb.g, this.b + rgb.b);
}
sub(rgb) {
return new Box3RGBColor(this.r - rgb.r, this.g - rgb.g, this.b - rgb.b);
}
mul(rgb) {
return new Box3RGBColor(this.r * rgb.r, this.g * rgb.g, this.b * rgb.b);
}
div(rgb) {
return new Box3RGBColor(rgb.r === 0 ? 0 : this.r / rgb.r, rgb.g === 0 ? 0 : this.g / rgb.g, rgb.b === 0 ? 0 : this.b / rgb.b);
}
addEq(rgb) {
this.r += rgb.r;
this.g += rgb.g;
this.b += rgb.b;
return this;
}
subEq(rgb) {
this.r -= rgb.r;
this.g -= rgb.g;
this.b -= rgb.b;
return this;
}
mulEq(rgb) {
this.r *= rgb.r;
this.g *= rgb.g;
this.b *= rgb.b;
return this;
}
divEq(rgb) {
this.r = rgb.r === 0 ? 0 : this.r / rgb.r;
this.g = rgb.g === 0 ? 0 : this.g / rgb.g;
this.b = rgb.b === 0 ? 0 : this.b / rgb.b;
return this;
}
lerp(rgb, n) {
return new Box3RGBColor(this.r + (rgb.r - this.r) * n, this.g + (rgb.g - this.g) * n, this.b + (rgb.b - this.b) * n);
}
equals(rgb) {
return (Math.abs(this.r - rgb.r) < EPSILON &&
Math.abs(this.g - rgb.g) < EPSILON &&
Math.abs(this.b - rgb.b) < EPSILON);
}
clone() {
return new Box3RGBColor(this.r, this.g, this.b);
}
toRGBA() {
return new Box3RGBAColor(this.r, this.g, this.b, 1.0);
}
toString() {
return `{ r:${this.r}, g:${this.g}, b:${this.b} }`;
}
}
class Box3RaycastResult {
constructor(hit, hitEntity, hitVoxel, origin, direction, distance, hitPosition, normal, voxelIndex) {
this.hit = hit;
this.hitEntity = hitEntity;
this.hitVoxel = hitVoxel;
this.origin = origin;
this.direction = direction;
this.distance = distance;
this.hitPosition = hitPosition;
this.normal = normal;
this.voxelIndex = voxelIndex;
}
}
class Box3ResourceSystem {
constructor(ls) {
this.ls = ls;
}
}
class Box3RespawnEvent {
constructor(tick, entity) {
this.tick = tick;
this.entity = entity;
}
}
class Box3SoundEffect {
constructor() {
this.radius = 32;
this.gain = 1;
this.gainRange = 0;
this.pitch = 1;
this.pitchRange = 0;
this.sample = '';
}
}
class Box3TickEvent {
constructor(tick, prevTick, skip, elapsedTimeMS) {
this.tick = tick;
this.prevTick = prevTick;
this.skip = skip;
this.elapsedTimeMS = elapsedTimeMS;
}
}
class Box3TriggerEvent {
constructor(tick, entity) {
this.tick = tick;
this.entity = entity;
}
}
class Box3Vector3 {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
static fromPolar(mag, phi, theta) {
return new Box3Vector3(mag * Math.sin(theta) * Math.sin(phi), mag * Math.cos(theta), mag * Math.sin(theta) * Math.cos(phi));
}
set(x, y, z) {
this.x = +x;
this.y = +y;
this.z = +z;
return this;
}
copy(v) {
this.x = v.x;
this.y = v.y;
this.z = v.z;
return this;
}
add(v) {
return new Box3Vector3(this.x + v.x, this.y + v.y, this.z + v.z);
}
sub(v) {
return new Box3Vector3(this.x - v.x, this.y - v.y, this.z - v.z);
}
mul(v) {
return new Box3Vector3(this.x * v.x, this.y * v.y, this.z * v.z);
}
div(v) {
return new Box3Vector3(v.x === 0 ? 0 : this.x / v.x, v.y === 0 ? 0 : this.y / v.y, v.z === 0 ? 0 : this.z / v.z);
}
addEq(v) {
this.x += v.x;
this.y += v.y;
this.z += v.z;
return this;
}
subEq(v) {
this.x -= v.x;
this.y -= v.y;
this.z -= v.z;
return this;
}
mulEq(v) {
this.x *= v.x;
this.y *= v.y;
this.z *= v.z;
return this;
}
divEq(v) {
this.x = v.x === 0 ? 0 : this.x / v.x;
this.y = v.y === 0 ? 0 : this.y / v.y;
this.z = v.z === 0 ? 0 : this.z / v.z;
return this;
}
dot(v) {
return this.x * v.x + this.y * v.y + this.z * v.z;
}
cross(v) {
return new Box3Vector3(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x);
}
scale(n) {
return new Box3Vector3(this.x * n, this.y * n, this.z * n);
}
clone() {
return new Box3Vector3(this.x, this.y, this.z);
}
lerp(v, n) {
return new Box3Vector3(this.x + (v.x - this.x) * n, this.y + (v.y - this.y) * n, this.z + (v.z - this.z) * n);
}
mag() {
return Math.sqrt(this.dot(this));
}
sqrMag() {
return this.dot(this);
}
towards(v) {
return v.sub(this);
}
distance(v) {
return this.sub(v).mag();
}
normalize() {
const x = this.x;
const y = this.y;
const z = this.y;
let r = x * x + y * y + z * z;
if (r > 0) {
r = 1 / Math.sqrt(r);
}
return new Box3Vector3(x * r, y * r, z * r);
}
angle(v) {
let r = v.sqrMag() * this.sqrMag();
if (r > 0) {
r = 1 / Math.sqrt(r);
}
const cos = r * this.dot(v);
if (1 < cos) {
return 0;
}
else if (cos < -1) {
return Math.PI;
}
else {
return Math.acos(cos);
}
}
max(v) {
return new Box3Vector3(Math.max(this.x, v.x), Math.max(this.y, v.y), Math.max(this.z, v.z));
}
min(v) {
return new Box3Vector3(Math.min(this.x, v.x), Math.min(this.y, v.y), Math.min(this.z, v.z));
}
exactEquals(v) {
return this.x === v.x && this.y === v.y && this.z === v.z;
}
equals(v) {
return (Math.abs(this.x - v.x) < EPSILON &&
Math.abs(this.y - v.y) < EPSILON &&
Math.abs(this.z - v.z) < EPSILON);
}
toString() {
return `{ x:${this.x}, y:${this.y}, z:${this.z} }`;
}
}
class Box3VoxelContact {
constructor(x, y, z, voxel, force, axis) {
this.x = x;
this.y = y;
this.z = z;
this.voxel = voxel;
this.force = force;
this.axis = axis;
}
}
class Box3VoxelContactEvent {
constructor(tick, entity, x, y, z, voxel, axis, force) {
this.tick = tick;
this.entity = entity;
this.x = x;
this.y = y;
this.z = z;
this.voxel = voxel;
this.axis = axis;
this.force = force;
}
}
class Box3Voxels {
constructor(shape, VoxelTypes, id, name, setVoxel, getVoxel, getVoxelRotation, setVoxelId, getVoxelId) {
this.shape = shape;
this.VoxelTypes = VoxelTypes;
this.id = id;
this.name = name;
this.setVoxel = setVoxel;
this.getVoxel = getVoxel;
this.getVoxelRotation = getVoxelRotation;
this.setVoxelId = setVoxelId;
this.getVoxelId = getVoxelId;
}
}
class Box3Wearable {
constructor() {
this.player = null;
this.bodyPart = Box3BodyPart.HEAD;
this.mesh = '';
this.color = new math_1.Box3RGBColor(1, 1, 1);
this.emissive = 0;
this.metalness = 0;
this.shininess = 0;
this.orientation = new math_1.Box3Quaternion(0, 1, 0, 0);
this.scale = new math_1.Box3Vector3(1, 1, 1);
this.offset = new math_1.Box3Vector3(0, 0, 0);
}
remove() {
if (this.player) {
this.player.removeWearable(this);
}
}
}
class Box3World {
constructor(url, entityQuota, onRespawn, nextRespawn, createEntity, querySelector, querySelectorAll, testSelector, addCollisionFilter, removeCollisionFilter, clearCollisionFilters, collisionFilters, raycast, searchBox, animate, getAnimations, getEntityAnimations, getPlayerAnimations, onTick, nextTick, onTakeDamage, nextTakeDamage, onDie, nextDie, onPlayerJoin, nextPlayerJoin, onPlayerLeave, nextPlayerLeave, onEntityCreate, nextEntityCreate, onEntityDestroy, nextEntityDestroy, say, onChat, nextChat, onClick, nextClick, onPress, nextPress, onRelease, nextRelease, onEntityContact, nextEntityContact, onEntitySeparate, nextEntitySeparate, onVoxelContact, nextVoxelContact, onVoxelSeparate, nextVoxelSeparate, onFluidEnter, nextFluidEnter, onFluidLeave, nextFluidLeave, zones, addZone, removeZone, onInteract, nextInteract, sound) {
this.url = url;
this.entityQuota = entityQuota;
this.onRespawn = onRespawn;
this.nextRespawn = nextRespawn;
this.createEntity = createEntity;
this.querySelector = querySelector;
this.querySelectorAll = querySelectorAll;
this.testSelector = testSelector;
this.addCollisionFilter = addCollisionFilter;
this.removeCollisionFilter = removeCollisionFilter;
this.clearCollisionFilters = clearCollisionFilters;
this.collisionFilters = collisionFilters;
this.raycast = raycast;
this.searchBox = searchBox;
this.animate = animate;
this.getAnimations = getAnimations;
this.getEntityAnimations = getEntityAnimations;
this.getPlayerAnimations = getPlayerAnimations;
this.onTick = onTick;
this.nextTick = nextTick;
this.onTakeDamage = onTakeDamage;
this.nextTakeDamage = nextTakeDamage;
this.onDie = onDie;
this.nextDie = nextDie;
this.onPlayerJoin = onPlayerJoin;
this.nextPlayerJoin = nextPlayerJoin;
this.onPlayerLeave = onPlayerLeave;
this.nextPlayerLeave = nextPlayerLeave;
this.onEntityCreate = onEntityCreate;
this.nextEntityCreate = nextEntityCreate;
this.onEntityDestroy = onEntityDestroy;
this.nextEntityDestroy = nextEntityDestroy;
this.say = say;
this.onChat = onChat;
this.nextChat = nextChat;
this.onClick = onClick;
this.nextClick = nextClick;
this.onPress = onPress;
this.nextPress = nextPress;
this.onRelease = onRelease;
this.nextRelease = nextRelease;
this.onEntityContact = onEntityContact;
this.nextEntityContact = nextEntityContact;
this.onEntitySeparate = onEntitySeparate;
this.nextEntitySeparate = nextEntitySeparate;
this.onVoxelContact = onVoxelContact;
this.nextVoxelContact = nextVoxelContact;
this.onVoxelSeparate = onVoxelSeparate;
this.nextVoxelSeparate = nextVoxelSeparate;
this.onFluidEnter = onFluidEnter;
this.nextFluidEnter = nextFluidEnter;
this.onFluidLeave = onFluidLeave;
this.nextFluidLeave = nextFluidLeave;
this.zones = zones;
this.addZone = addZone;
this.removeZone = removeZone;
this.onInteract = onInteract;
this.nextInteract = nextInteract;
this.sound = sound;
this.projectName = 'Project';
this.currentTick = 0;
this.lightMode = 'natural';
this.sunPhase = 0;
this.sunFrequency = 0;
this.lunarPhase = 0;
this.sunDirection = new math_1.Box3Vector3(0, -1, 0);
this.sunLight = new math_1.Box3RGBColor(1000, 1000, 1000);
this.skyLeftLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyRightLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyBottomLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyTopLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyFrontLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyBackLight = new math_1.Box3RGBColor(0, 0, 0);
this.fogColor = new math_1.Box3RGBColor(1, 1, 1);
this.fogStartDistance = 0;
this.fogHeightOffset = 0;
this.fogHeightFalloff = 0.8;
this.fogUnifor喵ensity = 0;
this.maxFog = 1;
this.snowDensity = 0;
this.snowSizeLo = 0;
this.snowSizeHi = 1;
this.snowFallSpeed = 1;
this.snowSpinSpeed = 0;
this.snowColor = new math_1.Box3RGBAColor(1, 1, 1, 1);
this.snowTexture = '';
this.rainDensity = 0;
this.rainDirection = new math_1.Box3Vector3(0, 1, 0);
this.rainSpeed = 1;
this.rainSizeLo = 0;
this.rainSizeHi = 1;
this.rainInterference = 0;
this.rainColor = new math_1.Box3RGBAColor(1, 1, 1, 1);
this.gravity = -0.1;
this.airFriction = 0.001;
this.breakVoxelSound = new Box3SoundEffect();
this.placeVoxelSound = new Box3SoundEffect();
this.playerJoinSound = new Box3SoundEffect();
this.playerLeaveSound = new Box3SoundEffect();
this.ambientSound = new Box3SoundEffect();
}
}
class Box3Zone {
constructor(entities, onEnter, nextEnter, onLeave, nextLeave, remove) {
this.entities = entities;
this.onEnter = onEnter;
this.nextEnter = nextEnter;
this.onLeave = onLeave;
this.nextLeave = nextLeave;
this.remove = remove;
this.bounds = new math_1.Box3Bounds3(new math_1.Box3Vector3(0, 0, 0), new math_1.Box3Vector3(0, 0, 0));
this.selector = '*';
this.massScale = 0;
this.force = new math_1.Box3Vector3(0, 0, 0);
this.fogEnabled = false;
this.fogColor = new math_1.Box3RGBColor(1, 1, 1);
this.fogStartDistance = 0;
this.fogHeightOffset = -8;
this.fogHeightFalloff = 0.8;
this.fogDensity = 0;
this.fogMax = 1;
this.snowEnabled = false;
this.snowDensity = 1;
this.snowSizeLo = 0.1;
this.snowSizeHi = 1;
this.snowFallSpeed = 1;
this.snowSpinSpeed = 0;
this.snowColor = new math_1.Box3RGBAColor(1, 1, 1, 1);
this.snowTexture = 'snow/snow2.part';
this.rainEnabled = false;
this.rainDensity = 1;
this.rainDirection = new math_1.Box3Vector3(0, 1, 0);
this.rainSpeed = 1;
this.rainSizeLo = 0.5;
this.rainSizeHi = 0.5;
this.rainInterference = 0;
this.rainColor = new math_1.Box3RGBAColor(1, 1, 1, 1);
this.skyEnabled = false;
this.skyMode = 'natural';
this.skySunPhase = 4 / 24;
this.skySunFrequency = 0;
this.skyLunarPhase = 0;
this.skySunDirection = new math_1.Box3Vector3(0, -1, 0);
this.skySunLight = new math_1.Box3RGBColor(1000, 1000, 1000);
this.skyLeftLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyRightLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyBottomLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyTopLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyFrontLight = new math_1.Box3RGBColor(0, 0, 0);
this.skyBackLight = new math_1.Box3RGBColor(0, 0, 0);
}
}