babylon-mmd
Version:
babylon.js mmd loader and runtime
960 lines (887 loc) • 33.3 kB
JavaScript
let wasm;
let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8ArrayMemory0;
}
let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
const MAX_SAFARI_DECODE_BYTES = 2146435072;
let numBytesDecoded = 0;
function decodeText(ptr, len) {
numBytesDecoded += len;
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
cachedTextDecoder.decode();
numBytesDecoded = len;
}
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}
function getStringFromWasm0(ptr, len) {
ptr = ptr >>> 0;
return decodeText(ptr, len);
}
function logError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
let error = (function () {
try {
return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
} catch(_) {
return "<failed to stringify thrown value>";
}
}());
console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
throw e;
}
}
let WASM_VECTOR_LEN = 0;
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length, 1) >>> 0;
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len, 1) >>> 0;
const mem = getUint8ArrayMemory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
offset += ret.written;
ptr = realloc(ptr, len, offset, 1) >>> 0;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
}
return cachedDataViewMemory0;
}
export function init() {
wasm.init();
}
function _assertNum(n) {
if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`);
}
/**
* @param {number} size
* @returns {number}
*/
export function allocateBuffer(size) {
_assertNum(size);
const ret = wasm.allocateBuffer(size);
return ret >>> 0;
}
/**
* Deallocate a buffer allocated by `allocateBuffer`.
* # Safety
* `ptr` must be a pointer to a buffer allocated by `allocateBuffer`.
* @param {number} ptr
* @param {number} size
*/
export function deallocateBuffer(ptr, size) {
_assertNum(ptr);
_assertNum(size);
wasm.deallocateBuffer(ptr, size);
}
/**
* @returns {MmdRuntime}
*/
export function createMmdRuntime() {
const ret = wasm.createMmdRuntime();
return MmdRuntime.__wrap(ret);
}
/**
* @returns {AnimationPool}
*/
export function createAnimationPool() {
const ret = wasm.createAnimationPool();
return AnimationPool.__wrap(ret);
}
function isLikeNone(x) {
return x === undefined || x === null;
}
const AnimationPoolFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_animationpool_free(ptr >>> 0, 1));
export class AnimationPool {
constructor() {
throw new Error('cannot invoke `new` directly');
}
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(AnimationPool.prototype);
obj.__wbg_ptr = ptr;
AnimationPoolFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
AnimationPoolFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_animationpool_free(ptr, 0);
}
/**
* @param {number} count
* @returns {number}
*/
allocateLengthsBuffer(count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(count);
const ret = wasm.animationpool_allocateLengthsBuffer(this.__wbg_ptr, count);
return ret >>> 0;
}
/**
* @param {number} ptr
* @param {number} count
*/
deallocateLengthsBuffer(ptr, count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
_assertNum(count);
wasm.animationpool_deallocateLengthsBuffer(this.__wbg_ptr, ptr, count);
}
/**
* @param {number} track_lengths
* @param {number} track_count
* @returns {number}
*/
createBoneTracks(track_lengths, track_count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(track_lengths);
_assertNum(track_count);
const ret = wasm.animationpool_createBoneTracks(this.__wbg_ptr, track_lengths, track_count);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getBoneTrackFrameNumbers(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getBoneTrackFrameNumbers(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getBoneTrackRotations(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getBoneTrackRotations(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getBoneTrackRotationInterpolations(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getBoneTrackRotationInterpolations(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getBoneTrackPhysicsToggles(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getBoneTrackPhysicsToggles(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} track_lengths
* @param {number} track_count
* @returns {number}
*/
createMovableBoneTracks(track_lengths, track_count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(track_lengths);
_assertNum(track_count);
const ret = wasm.animationpool_createMovableBoneTracks(this.__wbg_ptr, track_lengths, track_count);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackFrameNumbers(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackFrameNumbers(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackPositions(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackPositions(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackPositionInterpolations(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackPositionInterpolations(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackRotations(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackRotations(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackRotationInterpolations(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackRotationInterpolations(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMovableBoneTrackPhysicsToggles(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMovableBoneTrackPhysicsToggles(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} track_lengths
* @param {number} track_count
* @returns {number}
*/
createMorphTracks(track_lengths, track_count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(track_lengths);
_assertNum(track_count);
const ret = wasm.animationpool_createMorphTracks(this.__wbg_ptr, track_lengths, track_count);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMorphTrackFrameNumbers(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMorphTrackFrameNumbers(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} tracks
* @param {number} index
* @returns {number}
*/
getMorphTrackWeights(tracks, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(tracks);
_assertNum(index);
const ret = wasm.animationpool_getMorphTrackWeights(this.__wbg_ptr, tracks, index);
return ret >>> 0;
}
/**
* @param {number} bone_tracks_ptr
* @param {number} bone_track_count
* @param {number} movable_bone_tracks_ptr
* @param {number} movable_bone_track_count
* @param {number} morph_tracks_ptr
* @param {number} morph_track_count
* @param {number} property_track_length
* @param {number} property_track_ik_count
* @returns {number}
*/
createAnimation(bone_tracks_ptr, bone_track_count, movable_bone_tracks_ptr, movable_bone_track_count, morph_tracks_ptr, morph_track_count, property_track_length, property_track_ik_count) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(bone_tracks_ptr);
_assertNum(bone_track_count);
_assertNum(movable_bone_tracks_ptr);
_assertNum(movable_bone_track_count);
_assertNum(morph_tracks_ptr);
_assertNum(morph_track_count);
_assertNum(property_track_length);
_assertNum(property_track_ik_count);
const ret = wasm.animationpool_createAnimation(this.__wbg_ptr, bone_tracks_ptr, bone_track_count, movable_bone_tracks_ptr, movable_bone_track_count, morph_tracks_ptr, morph_track_count, property_track_length, property_track_ik_count);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @returns {number}
*/
getPropertyTrackFrameNumbers(animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
const ret = wasm.animationpool_getPropertyTrackFrameNumbers(this.__wbg_ptr, animation_ptr);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @param {number} index
* @returns {number}
*/
getPropertyTrackIkStates(animation_ptr, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
_assertNum(index);
const ret = wasm.animationpool_getPropertyTrackIkStates(this.__wbg_ptr, animation_ptr, index);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
*/
destroyAnimation(animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
wasm.animationpool_destroyAnimation(this.__wbg_ptr, animation_ptr);
}
/**
* @param {number} animation_ptr
* @returns {number}
*/
createBoneBindIndexMap(animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
const ret = wasm.animationpool_createBoneBindIndexMap(this.__wbg_ptr, animation_ptr);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @returns {number}
*/
createMovableBoneBindIndexMap(animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
const ret = wasm.animationpool_createMovableBoneBindIndexMap(this.__wbg_ptr, animation_ptr);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @param {number} morph_lengths
* @returns {number}
*/
createMorphBindIndexMap(animation_ptr, morph_lengths) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
_assertNum(morph_lengths);
const ret = wasm.animationpool_createMorphBindIndexMap(this.__wbg_ptr, animation_ptr, morph_lengths);
return ret >>> 0;
}
/**
* @param {number} morph_bind_index_map
* @param {number} index
* @returns {number}
*/
getNthMorphBindIndexMap(morph_bind_index_map, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(morph_bind_index_map);
_assertNum(index);
const ret = wasm.animationpool_getNthBoneToBodyBindIndexMap(this.__wbg_ptr, morph_bind_index_map, index);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @returns {number}
*/
createIkSolverBindIndexMap(animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
const ret = wasm.animationpool_createIkSolverBindIndexMap(this.__wbg_ptr, animation_ptr);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @param {number} body_lengths
* @returns {number}
*/
createBoneToBodyBindIndexMap(animation_ptr, body_lengths) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
_assertNum(body_lengths);
const ret = wasm.animationpool_createBoneToBodyBindIndexMap(this.__wbg_ptr, animation_ptr, body_lengths);
return ret >>> 0;
}
/**
* @param {number} bone_to_body_bind_index_map
* @param {number} index
* @returns {number}
*/
getNthBoneToBodyBindIndexMap(bone_to_body_bind_index_map, index) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(bone_to_body_bind_index_map);
_assertNum(index);
const ret = wasm.animationpool_getNthBoneToBodyBindIndexMap(this.__wbg_ptr, bone_to_body_bind_index_map, index);
return ret >>> 0;
}
/**
* @param {number} animation_ptr
* @param {number} bone_bind_index_map
* @param {number} movable_bone_bind_index_map
* @param {number} morph_bind_index_map
* @param {number} ik_solver_bind_index_map
* @param {number} bone_to_body_bind_index_map
* @returns {number}
*/
createRuntimeAnimation(animation_ptr, bone_bind_index_map, movable_bone_bind_index_map, morph_bind_index_map, ik_solver_bind_index_map, bone_to_body_bind_index_map) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
_assertNum(bone_bind_index_map);
_assertNum(movable_bone_bind_index_map);
_assertNum(morph_bind_index_map);
_assertNum(ik_solver_bind_index_map);
_assertNum(bone_to_body_bind_index_map);
const ret = wasm.animationpool_createRuntimeAnimation(this.__wbg_ptr, animation_ptr, bone_bind_index_map, movable_bone_bind_index_map, morph_bind_index_map, ik_solver_bind_index_map, bone_to_body_bind_index_map);
return ret >>> 0;
}
/**
* @param {number} runtime_animation_ptr
*/
destroyRuntimeAnimation(runtime_animation_ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(runtime_animation_ptr);
wasm.animationpool_destroyRuntimeAnimation(this.__wbg_ptr, runtime_animation_ptr);
}
/**
* @param {number} animation_ptr
* @param {number} mmd_model_ptr
* @param {number} frame_time
*/
animateMmdModel(animation_ptr, mmd_model_ptr, frame_time) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(animation_ptr);
_assertNum(mmd_model_ptr);
wasm.animationpool_animateMmdModel(this.__wbg_ptr, animation_ptr, mmd_model_ptr, frame_time);
}
}
const MmdRuntimeFinalization = (typeof FinalizationRegistry === 'undefined')
? { register: () => {}, unregister: () => {} }
: new FinalizationRegistry(ptr => wasm.__wbg_mmdruntime_free(ptr >>> 0, 1));
export class MmdRuntime {
constructor() {
throw new Error('cannot invoke `new` directly');
}
static __wrap(ptr) {
ptr = ptr >>> 0;
const obj = Object.create(MmdRuntime.prototype);
obj.__wbg_ptr = ptr;
MmdRuntimeFinalization.register(obj, obj.__wbg_ptr, obj);
return obj;
}
__destroy_into_raw() {
const ptr = this.__wbg_ptr;
this.__wbg_ptr = 0;
MmdRuntimeFinalization.unregister(this);
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_mmdruntime_free(ptr, 0);
}
/**
* @param {number} serialized_metadata_ptr
* @param {number} serialized_metadata_size
* @returns {number}
*/
createMmdModel(serialized_metadata_ptr, serialized_metadata_size) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(serialized_metadata_ptr);
_assertNum(serialized_metadata_size);
const ret = wasm.mmdruntime_createMmdModel(this.__wbg_ptr, serialized_metadata_ptr, serialized_metadata_size);
return ret >>> 0;
}
/**
* @param {number} ptr
*/
destroyMmdModel(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
wasm.mmdruntime_destroyMmdModel(this.__wbg_ptr, ptr);
}
/**
* @param {number} ptr
* @returns {number}
*/
getAnimationArena(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getAnimationArena(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
getAnimationIkSolverStateArena(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getAnimationIkSolverStateArena(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
getAnimationRigidBodyStateArena(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getAnimationRigidBodyStateArena(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
getAnimationRigidBodyStateArenaSize(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getAnimationRigidBodyStateArenaSize(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
getAnimationMorphArena(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getAnimationMorphArena(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
getBoneWorldMatrixArena(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_getBoneWorldMatrixArena(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @returns {number}
*/
createBoneWorldMatrixBackBuffer(ptr) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
const ret = wasm.mmdruntime_createBoneWorldMatrixBackBuffer(this.__wbg_ptr, ptr);
return ret >>> 0;
}
/**
* @param {number} ptr
* @param {number} runtime_animation
*/
setRuntimeAnimation(ptr, runtime_animation) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
_assertNum(runtime_animation);
wasm.mmdruntime_setRuntimeAnimation(this.__wbg_ptr, ptr, runtime_animation);
}
/**
* @param {number} ptr
* @param {number} rigidbody_state_size
*/
useExternalPhysics(ptr, rigidbody_state_size) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
_assertNum(ptr);
_assertNum(rigidbody_state_size);
wasm.mmdruntime_useExternalPhysics(this.__wbg_ptr, ptr, rigidbody_state_size);
}
/**
* @param {number | null} [frame_time]
*/
beforePhysics(frame_time) {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
if (!isLikeNone(frame_time)) {
_assertNum(frame_time);
}
wasm.mmdruntime_beforePhysics(this.__wbg_ptr, isLikeNone(frame_time) ? 0x100000001 : Math.fround(frame_time));
}
afterPhysics() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
wasm.mmdruntime_afterPhysics(this.__wbg_ptr);
}
/**
* @returns {number}
*/
getLockStatePtr() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
const ret = wasm.mmdruntime_getLockStatePtr(this.__wbg_ptr);
return ret >>> 0;
}
swapWorldMatrixBuffer() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
wasm.mmdruntime_swapWorldMatrixBuffer(this.__wbg_ptr);
}
/**
* @returns {number}
*/
acquireDiagnosticErrorResult() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
const ret = wasm.mmdruntime_acquireDiagnosticErrorResult(this.__wbg_ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
acquireDiagnosticWarningResult() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
const ret = wasm.mmdruntime_acquireDiagnosticWarningResult(this.__wbg_ptr);
return ret >>> 0;
}
/**
* @returns {number}
*/
acquireDiagnosticInfoResult() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
const ret = wasm.mmdruntime_acquireDiagnosticInfoResult(this.__wbg_ptr);
return ret >>> 0;
}
releaseDiagnosticResult() {
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
_assertNum(this.__wbg_ptr);
wasm.mmdruntime_releaseDiagnosticResult(this.__wbg_ptr);
}
}
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
try {
return await WebAssembly.instantiateStreaming(module, imports);
} catch (e) {
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
} else {
throw e;
}
}
}
const bytes = await module.arrayBuffer();
return await WebAssembly.instantiate(bytes, imports);
} else {
const instance = await WebAssembly.instantiate(module, imports);
if (instance instanceof WebAssembly.Instance) {
return { instance, module };
} else {
return instance;
}
}
}
function __wbg_get_imports() {
const imports = {};
imports.wbg = {};
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function() { return logError(function (arg0, arg1) {
let deferred0_0;
let deferred0_1;
try {
deferred0_0 = arg0;
deferred0_1 = arg1;
console.error(getStringFromWasm0(arg0, arg1));
} finally {
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
}
}, arguments) };
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { return logError(function () {
const ret = new Error();
return ret;
}, arguments) };
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function() { return logError(function (arg0, arg1) {
const ret = arg1.stack;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
}, arguments) };
imports.wbg.__wbindgen_init_externref_table = function() {
const table = wasm.__wbindgen_export_3;
const offset = table.grow(4);
table.set(0, undefined);
table.set(offset + 0, undefined);
table.set(offset + 1, null);
table.set(offset + 2, true);
table.set(offset + 3, false);
;
};
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
return imports;
}
function __wbg_init_memory(imports, memory) {
}
function __wbg_finalize_init(instance, module) {
wasm = instance.exports;
__wbg_init.__wbindgen_wasm_module = module;
cachedDataViewMemory0 = null;
cachedUint8ArrayMemory0 = null;
wasm.__wbindgen_start();
return wasm;
}
function initSync(module) {
if (wasm !== undefined) return wasm;
if (typeof module !== 'undefined') {
if (Object.getPrototypeOf(module) === Object.prototype) {
({module} = module)
} else {
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
}
}
const imports = __wbg_get_imports();
__wbg_init_memory(imports);
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, imports);
return __wbg_finalize_init(instance, module);
}
async function __wbg_init(module_or_path) {
if (wasm !== undefined) return wasm;
if (typeof module_or_path !== 'undefined') {
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
({module_or_path} = module_or_path)
} else {
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
}
}
if (typeof module_or_path === 'undefined') {
module_or_path = new URL('index_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
module_or_path = fetch(module_or_path);
}
__wbg_init_memory(imports);
const { instance, module } = await __wbg_load(await module_or_path, imports);
return __wbg_finalize_init(instance, module);
}
export { initSync };
export default __wbg_init;