瀏覽代碼

大致调通了,人物缩放还有点问题

xushiting 3 年之前
父節點
當前提交
805290a298

+ 353 - 10
dist/index.html

@@ -34,7 +34,7 @@
     <script src="./libs/axios.min.js"></script>
     <script src="./libs/VisibilityChangeHandler.js"></script>
     <script src="./libs/decoder.js"></script>
-    <script src="./libs/decoder.js"></script>
+    <script src="./libs/nipplejs.min.js"></script>
     <script src="./shader.js"></script>
 
     <!-- <script src="./webrtc//adapter-7.4.0.min.js"></script>
@@ -336,7 +336,8 @@ const WASM_Version = "h264"
         }
         )))
     };
-    objectParseFloat = (i) => {
+    
+    const objectParseFloat = (i) => {
         const e = {};
         return (
         i &&
@@ -346,15 +347,357 @@ const WASM_Version = "h264"
         e
         );
     }
-    getRandomItem = (i) =>
-    i.length === 0 ? null : i[Math.floor(Math.random() * i.length)]
-    
-    function uuid$1() {
-    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (i) => {
-        const e = (Math.random() * 16) | 0;
-        return (i === "x" ? e : (e & 3) | 8).toString(16);
-    });
+    getRandomItem = (i) =>i.length === 0 ? null : i[Math.floor(Math.random() * i.length)]
+
+    const safeDecodeURIComponent = i=>{
+        let e = "";
+        try {
+            e = decodeURIComponent(i)
+        } catch {
+            e = i
+        }
+        return e
+    }
+    const safelyJsonParse = i=>{
+        let e = {};
+        try {
+            e = JSON.parse(i)
+        } catch {}
+        return e
+    }
+
+    var EventState = function() {
+    function i(e, t, r, n) {
+        t === void 0 && (t = !1),
+        this.initialize(e, t, r, n)
+    }
+    return i.prototype.initialize = function(e, t, r, n) {
+        return t === void 0 && (t = !1),
+        this.mask = e,
+        this.skipNextObservers = t,
+        this.target = r,
+        this.currentTarget = n,
+        this
+    }
+    ,
+    i
+}()
+  , Observer = function() {
+    function i(e, t, r) {
+        r === void 0 && (r = null),
+        this.callback = e,
+        this.mask = t,
+        this.scope = r,
+        this._willBeUnregistered = !1,
+        this.unregisterOnNextCall = !1
+    }
+    return i
+}()
+  , Observable = function() {
+    function i(e) {
+        this._observers = new Array,
+        this._eventState = new EventState(0),
+        e && (this._onObserverAdded = e)
+    }
+    return i.FromPromise = function(e, t) {
+        var r = new i;
+        return e.then(function(n) {
+            r.notifyObservers(n)
+        }).catch(function(n) {
+            if (t)
+                t.notifyObservers(n);
+            else
+                throw n
+        }),
+        r
+    }
+    ,
+    Object.defineProperty(i.prototype, "observers", {
+        get: function() {
+            return this._observers
+        },
+        enumerable: !1,
+        configurable: !0
+    }),
+    i.prototype.add = function(e, t, r, n, o) {
+        if (t === void 0 && (t = -1),
+        r === void 0 && (r = !1),
+        n === void 0 && (n = null),
+        o === void 0 && (o = !1),
+        !e)
+            return null;
+        var a = new Observer(e,t,n);
+        return a.unregisterOnNextCall = o,
+        r ? this._observers.unshift(a) : this._observers.push(a),
+        this._onObserverAdded && this._onObserverAdded(a),
+        a
+    }
+    ,
+    i.prototype.addOnce = function(e) {
+        return this.add(e, void 0, void 0, void 0, !0)
+    }
+    ,
+    i.prototype.remove = function(e) {
+        if (!e)
+            return !1;
+        var t = this._observers.indexOf(e);
+        return t !== -1 ? (this._deferUnregister(e),
+        !0) : !1
+    }
+    ,
+    i.prototype.removeCallback = function(e, t) {
+        for (var r = 0; r < this._observers.length; r++) {
+            var n = this._observers[r];
+            if (!n._willBeUnregistered && n.callback === e && (!t || t === n.scope))
+                return this._deferUnregister(n),
+                !0
+        }
+        return !1
+    }
+    ,
+    i.prototype._deferUnregister = function(e) {
+        var t = this;
+        e.unregisterOnNextCall = !1,
+        e._willBeUnregistered = !0,
+        setTimeout(function() {
+            t._remove(e)
+        }, 0)
+    }
+    ,
+    i.prototype._remove = function(e) {
+        if (!e)
+            return !1;
+        var t = this._observers.indexOf(e);
+        return t !== -1 ? (this._observers.splice(t, 1),
+        !0) : !1
+    }
+    ,
+    i.prototype.makeObserverTopPriority = function(e) {
+        this._remove(e),
+        this._observers.unshift(e)
+    }
+    ,
+    i.prototype.makeObserverBottomPriority = function(e) {
+        this._remove(e),
+        this._observers.push(e)
+    }
+    ,
+    i.prototype.notifyObservers = function(e, t, r, n, o) {
+        if (t === void 0 && (t = -1),
+        !this._observers.length)
+            return !0;
+        var a = this._eventState;
+        a.mask = t,
+        a.target = r,
+        a.currentTarget = n,
+        a.skipNextObservers = !1,
+        a.lastReturnValue = e,
+        a.userInfo = o;
+        for (var s = 0, l = this._observers; s < l.length; s++) {
+            var u = l[s];
+            if (!u._willBeUnregistered && (u.mask & t && (u.scope ? a.lastReturnValue = u.callback.apply(u.scope, [e, a]) : a.lastReturnValue = u.callback(e, a),
+            u.unregisterOnNextCall && this._deferUnregister(u)),
+            a.skipNextObservers))
+                return !1
+        }
+        return !0
+    }
+    ,
+    i.prototype.notifyObserversWithPromise = function(e, t, r, n, o) {
+        var a = this;
+        t === void 0 && (t = -1);
+        var s = Promise.resolve(e);
+        if (!this._observers.length)
+            return s;
+        var l = this._eventState;
+        return l.mask = t,
+        l.target = r,
+        l.currentTarget = n,
+        l.skipNextObservers = !1,
+        l.userInfo = o,
+        this._observers.forEach(function(u) {
+            l.skipNextObservers || u._willBeUnregistered || u.mask & t && (u.scope ? s = s.then(function(c) {
+                return l.lastReturnValue = c,
+                u.callback.apply(u.scope, [e, l])
+            }) : s = s.then(function(c) {
+                return l.lastReturnValue = c,
+                u.callback(e, l)
+            }),
+            u.unregisterOnNextCall && a._deferUnregister(u))
+        }),
+        s.then(function() {
+            return e
+        })
+    }
+    ,
+    i.prototype.notifyObserver = function(e, t, r) {
+        if (r === void 0 && (r = -1),
+        !e._willBeUnregistered) {
+            var n = this._eventState;
+            n.mask = r,
+            n.skipNextObservers = !1,
+            e.callback(t, n),
+            e.unregisterOnNextCall && this._deferUnregister(e)
+        }
+    }
+    ,
+    i.prototype.hasObservers = function() {
+        return this._observers.length > 0
+    }
+    ,
+    i.prototype.clear = function() {
+        this._observers = new Array,
+        this._onObserverAdded = null
     }
+    ,
+    i.prototype.clone = function() {
+        var e = new i;
+        return e._observers = this._observers.slice(0),
+        e
+    }
+    ,
+    i.prototype.hasSpecificMask = function(e) {
+        e === void 0 && (e = -1);
+        for (var t = 0, r = this._observers; t < r.length; t++) {
+            var n = r[t];
+            if (n.mask & e || n.mask === e)
+                return !0
+        }
+        return !1
+    }
+    ,
+    i
+}();
+
+const safeParseComponents = i=>{
+    let e = [];
+    try {
+        e = JSON.parse(i || "[]")
+    } catch {
+        e = [],
+        log$2.error(`avatarComponents parse error: ${i}`)
+    }
+    return e
+}
+
+const avatarComponentsModify = (i,e)=>new Promise((t,r)=>{
+    var l;
+    let n = [];
+    const o = []
+      , a = [];
+    let s = e.some(u=>isSuit(u.type));
+    if ((l = i == null ? void 0 : i.components) == null || l.forEach(u=>{
+        var f;
+        const c = e.find(d=>d.type === u.type)
+          , h = c && ((f = i == null ? void 0 : i.components) == null ? void 0 : f.find(d=>d.type === c.type && d.units.some(_=>_.id === c.id))) !== void 0;
+        if (c)
+            if (h)
+                n.push(c);
+            else {
+                const d = u.units.find(_=>_.isDefault) || u.units[0];
+                d ? n.push({
+                    type: u.type,
+                    id: d.id
+                }) : o.push(`component with type: ${u.type} without default and available unit`)
+            }
+        else if (isSuit(u.type)) {
+            const d = u.units.find(_=>_.isDefault);
+            d && n.push({
+                type: u.type,
+                id: d.id
+            })
+        } else {
+            const d = u.units.find(_=>_.isDefault) || u.units[0];
+            d ? n.push({
+                type: u.type,
+                id: d.id
+            }) : o.push(`component with type: ${u.type} without default and available unit`)
+        }
+    }
+    ),
+    s = n.some(u=>isSuit(u.type)),
+    s) {
+        const u = i == null ? void 0 : i.components.find(c=>isSuit(c.type));
+        n = n.filter(c=>(u == null ? void 0 : u.suitComb.indexOf(c.type)) === -1)
+    }
+    o.length > 0 && (log$2.error(o.join(", ")),
+    r(o.join(", "))),
+    a.length > 0 && log$2.warn(a.join(", ")),
+    t(n)
+}
+)
+
+const isSuit = i=>i === "suit"
+
+const positionPrecisionProtect = i=>{
+    const {x: e, y: t, z: r} = i;
+    return {
+        x: +e.toFixed(2),
+        y: +t.toFixed(2),
+        z: +r.toFixed(2)
+    }
+}
+
+const avatarComponentsParser = async(i=null,e,t=[])=>new Promise(async(r,n)=>{
+    var u, c;
+    if (e.find(h=>isSuit(h.type))) {
+        const h = (c = (u = i == null ? void 0 : i.components) == null ? void 0 : u.find(f=>isSuit(f.type))) == null ? void 0 : c.suitComb;
+        e = e.filter(f=>(h == null ? void 0 : h.indexOf(f.type)) === -1)
+    }
+    const a = e.filter(h=>!t.some(f=>f.id === h.id));
+    a.length === 0 && r([]);
+    const s = [];
+    a.forEach(async h=>{
+        var _;
+        let f = (_ = i == null ? void 0 : i.components) == null ? void 0 : _.find(g=>g.type === h.type);
+        if (!f) {
+            const g = `changeComponents, no such component with type: ${h.type}`;
+            log$2.error(g),
+            n(g)
+        }
+        f = JSON.parse(JSON.stringify(f));
+        let d = f == null ? void 0 : f.units.find(g=>g.id === h.id);
+        d || (log$2.warn(`changeComponents, no unit with type: ${h.type}, id: ${h.id}`),
+        d = f == null ? void 0 : f.units.find(g=>g.isDefault),
+        !d && log$2.warn(`changeComponents, no default unit with type: ${h.type}`)),
+        d && s.push({
+            id: d.id,
+            url: d.url,
+            suitComb: (f == null ? void 0 : f.suitComb) || [],
+            type: h.type
+        })
+    }
+    );
+    const l = [];
+    Promise.all(l).then(h=>{
+        s.forEach((f,d)=>{
+            var _, g;
+            if (!isSuit(f.type)) {
+                const m = ((g = (_ = i == null ? void 0 : i.components) == null ? void 0 : _.find(v=>isSuit(v.type))) == null ? void 0 : g.suitComb) || [];
+                m.length > 0 && (m == null ? void 0 : m.indexOf(f.type)) !== -1 && (f.suitComb = ["suit"])
+            }
+            f.url = h[d]
+        }
+        ),
+        r(s)
+    }
+    ).catch(h=>{
+        n(h)
+    }
+    )
+}
+)
+
+const rotationPrecisionProtect = i=>{
+    const {pitch: e, yaw: t, roll: r} = i;
+    return {
+        pitch: +e.toFixed(2),
+        yaw: +t.toFixed(2),
+        roll: +r.toFixed(2)
+    }
+}
+
+const getAnimationKey = (i,e)=>e + "_" + i
 
     </script>
 

File diff suppressed because it is too large
+ 10523 - 7226
dist/js/index.js


File diff suppressed because it is too large
+ 1 - 1
dist/js/index.js.map


File diff suppressed because it is too large
+ 136110 - 2
dist/libs/babylon.js


+ 2 - 0
src/ActionsHandler.js

@@ -3,6 +3,8 @@ import Actions from "./enum/Actions.js"
 import {logger} from "./Logger.js"
 import {eventsManager} from "./EventsManager.js"
 import util from "./util.js"
+import Person from "./enum/Person.js"
+import ClickType from "./enum/ClickType.js"
 
 const QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
 export default class ActionsHandler {

+ 1 - 1
src/BreathPoint.js

@@ -1,4 +1,4 @@
-class BreathPoint {
+export default class BreathPoint {
     constructor(e) {
         E(this, "_staticmesh");
         E(this, "_id");

+ 1 - 1
src/Debug.js

@@ -1,7 +1,7 @@
 const BREATH_POINT_TYPE = "debugBreathPoint"
   , TAP_BREATH_POINT_TYPE = "debugTapBreathPoint"
   , DEFAULT_SEARCH_RANGE = 1e3;
-class Debug {
+export default class Debug {
     constructor(e) {
         E(this, "isShowNearbyBreathPoints", !1);
         E(this, "isShowTapBreathPoints", !1);

+ 1 - 1
src/Error/AvatarAnimationError.js

@@ -1,6 +1,6 @@
 import XverseError from "./XverseError.js"
 
-export default class AvatarAnimationError extends XverseError$1 {
+export default class AvatarAnimationError extends XverseError {
     constructor(e) {
         super(5101, e || "[Engine] \u89D2\u8272\u52A8\u753B\u64AD\u653E\u5931\u8D25")
     }

+ 5 - 4
src/EventsManager.js

@@ -1,5 +1,6 @@
 import {logger} from "./Logger.js"
 import Actions from "./enum/Actions.js"
+import Codes from "./enum/Codes.js"
 import util from "./util.js"
 
 export default class EventsManager extends EventEmitter {
@@ -9,7 +10,7 @@ export default class EventsManager extends EventEmitter {
         E(this, "specialEvents", new Map)
     }
     remove(e, t, r, n) {
-        if (this.specialEvents.has(e) && !n && t === Codes$1.Success)
+        if (this.specialEvents.has(e) && !n && t === Codes.Success)
             return;
         this.events.get(e) && (this.emit(e, {
             code: t,
@@ -36,7 +37,7 @@ export default class EventsManager extends EventEmitter {
                 this.events.delete(r),
                 h(void 0);
             this.on(r, ({code: _, data: g, msg: m})=>{
-                if (_ === Codes$1.Success)
+                if (_ === Codes.Success)
                     h(g),
                     this.off(r),
                     logger.infoAndReportMeasurement({
@@ -47,9 +48,9 @@ export default class EventsManager extends EventEmitter {
                         traceId: r
                     });
                 else {
-                    if (_ === Codes$1.ActionMaybeDelay)
+                    if (_ === Codes.ActionMaybeDelay)
                         return;
-                    if (_ === Codes$1.DoActionBlocked && e.event === Actions.Rotation) {
+                    if (_ === Codes.DoActionBlocked && e.event === Actions.Rotation) {
                         logger.debug(s + " response code: " + _);
                         return
                     }

+ 2 - 0
src/PathManager.js

@@ -1,3 +1,5 @@
+import MotionType from "./enum/MotionType.js"
+
 export default class PathManager {
     constructor() {
         this.currentArea = ''

+ 1 - 1
src/PoolObject.js

@@ -10,7 +10,7 @@ export default class PoolObject {
         this.free = n
     }
     dispose() {
-        this.data && this.data instanceof Mesh && this.data.dispose(!0, !0),
+        this.data && this.data instanceof BABYLON.Mesh && this.data.dispose(!0, !0),
         this.previousFree = null,
         this.nextFree = null,
         this.data = null

+ 1 - 1
src/Queue.js

@@ -1,4 +1,4 @@
-class Queue {
+export default class Queue {
     constructor() {
         E(this, "queue", []);
         E(this, "currentAction")

+ 1 - 0
src/Signal.js

@@ -4,6 +4,7 @@ import {logger} from "./Logger.js"
 import {eventsManager} from "./EventsManager.js"
 import ECurrentShaderMode from "./enum/ECurrentShaderMode.js"
 import Actions from "./enum/Actions.js"
+import PointType from "./enum/PointType.js"
 
 export default class Signal {
     constructor(e) {

+ 1 - 0
src/XAnimationController.js

@@ -1,6 +1,7 @@
 //const avatarLoader = new XAvatarLoader
 // log$J = new Logger$1("AnimationController");
 import {avatarLoader} from "./XAvatarLoader.js"
+import {logger} from "./Logger.js"
 import AvatarAnimationError from "./error/AvatarAnimationError.js"
 
 export default class XAnimationController {

+ 6 - 2
src/XAvatar.js

@@ -2,6 +2,10 @@
 
 import BillboardStatus from "./enum/BillboardStatus.js"
 import {avatarLoader} from "./XAvatarLoader.js"
+import XAnimationController from "./XAnimationController.js"
+import XAvatarComopnent from "./XAvatarComopnent.js"
+import XStateMachine from "./XStateMachine.js"
+import XAvatarBillboardComponent from "./XAvatarBillboardComponent.js"
 
 const castRayOffsetY = .01;
 const castRayTeleportationOffset = 10;
@@ -73,7 +77,7 @@ export default class XAvatar {
         this.component = new XAvatarComopnent,
         this.stateMachine = new XStateMachine(this._scene),
         this.bbComponent = new XAvatarBillboardComponent(this._scene),
-        this.rootNode = new TransformNode(e,this._avatarManager.scene),
+        this.rootNode = new BABYLON.TransformNode(e,this._avatarManager.scene),
         this._avatarScale = a.avatarScale == null ? 1 : a.avatarScale,
         this._avatarRotation = a.avatarRotation == null ? {
             pitch: 0,
@@ -281,7 +285,7 @@ export default class XAvatar {
               , s = 100 * a
               , l = a
               , u = new BABYLON.Vector3(n.x,n.y + l,+n.z)
-              , c = new Ray(u,o,s)
+              , c = new BABYLON.Ray(u,o,s)
               , h = (d = this.avatarManager.sceneManager) == null ? void 0 : d.getGround(e);
             if (!h || h.length <= 0)
                 return logger.warn(`\u89D2\u8272 id= ${this.id} \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6`),

+ 1 - 1
src/XAvatarBillboardComponent.js

@@ -123,7 +123,7 @@ export default class XAvatarBillboardComponent {
                     c.z = f.bbComponent.bbox.maximum.z)
                 }
                 const h = e.rootNode.computeWorldMatrix(!0);
-                if (this.bbox ? this.bbox.reConstruct(u, c, h) : this.bbox = new BoundingBox(u,c,h),
+                if (this.bbox ? this.bbox.reConstruct(u, c, h) : this.bbox = new BABYLON.BoundingBox(u,c,h),
                 this._pickBbox == null) {
                     const f = this.createPickBoundingbox(e, this.bbox);
                     this.attachToAvatar(e, f.data, !1, {

+ 1 - 0
src/XAvatarManager.js

@@ -2,6 +2,7 @@ import {logger} from "./Logger.js"
 import Pool from "./Pool"
 import BillboardStatus from "./enum/BillboardStatus.js"
 import {avatarLoader} from "./XAvatarLoader.js"
+import XAvatar from "./XAvatar.js"
 
 export default class XAvatarManager {
     constructor(e) {

+ 1 - 0
src/XBillboardManager.js

@@ -2,6 +2,7 @@ const texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/"
 
 import BillboardStatus from "./enum/BillboardStatus.js"
 import Pool from "./Pool.js"
+import XBillboard from "./XBillboard.js"
 
 export default class XBillboardManager {
     constructor(e) {

+ 8 - 7
src/XBreathPointManager.js

@@ -1,6 +1,7 @@
 import XStaticMesh from "./XStaticMesh.js"
 import {logger} from "./Logger.js"
 import EMeshType from "./enum/EMeshType.js"
+import BreathPoint from "./BreathPoint.js"
 
 export default class XBreathPointManager {
     constructor(e) {
@@ -40,13 +41,13 @@ export default class XBreathPointManager {
                 I.count = I.count + 1,
                 C = I.mat
             } else {
-                const I = new Texture(o,this._scene,!0,!0,Texture.BILINEAR_SAMPLINGMODE,null,()=>{
+                const I = new BABYLON.Texture(o,this._scene,!0,!0,BABYLON.Texture.BILINEAR_SAMPLINGMODE,null,()=>{
                     logger.error("[Engine] Breathpoint create texture error."),
                     new XBreathPointError("[Engine] Breathpoint create texture error.")
                 }
                 ,null,!0);
                 I.name = "TexBreathPoint_" + n,
-                C = new StandardMaterial(`MaterialBreathPoint_${n}`,this._scene),
+                C = new BABYLON.StandardMaterial(`MaterialBreathPoint_${n}`,this._scene),
                 C.alpha = 1,
                 C.emissiveTexture = I,
                 C.backFaceCulling = y,
@@ -66,9 +67,9 @@ export default class XBreathPointManager {
             }
             const A = new Array(6);
             for (let I = 0; I < 6; I++)
-                A[I] = new Vector4(0,0,0,0);
-            A[0] = new Vector4(0,0,1 / a,1 / s),
-            A[1] = new Vector4(0,0,1 / a,1 / s);
+                A[I] = new BABYLON.Vector4(0,0,0,0);
+            A[0] = new BABYLON.Vector4(0,0,1 / a,1 / s),
+            A[1] = new BABYLON.Vector4(0,0,1 / a,1 / s);
             let S = {};
             h > 0 && f > 0 ? S = {
                 width: h,
@@ -89,7 +90,7 @@ export default class XBreathPointManager {
                 skinInfo: T
             });
             let M = u;
-            _ && (P.billboardMode = Mesh.BILLBOARDMODE_ALL,
+            _ && (P.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL,
             R.allowMove(),
             M = {
                 pitch: 0,
@@ -194,7 +195,7 @@ export default class XBreathPointManager {
             z: e.z
         });
         const t = new BABYLON.Vector3(0,-1,0)
-          , r = new Ray(e,t,length)
+          , r = new BABYLON.Ray(e,t,length)
           , n = []
           , o = (s = this._sceneManager) == null ? void 0 : s.getGround({
             x: e.x,

+ 4 - 4
src/XDecalMaterial.js

@@ -27,7 +27,7 @@ export default class XDecalMaterial {
             r ? (this._tex = new BABYLON.DynamicTexture("dyTex",{
                 width: n,
                 height: o
-            },this.scene,!0,Texture.BILINEAR_SAMPLINGMODE),
+            },this.scene,!0,BABYLON.Texture.BILINEAR_SAMPLINGMODE),
             this._tex.name = "decal_dy_" + this._id,
             this._tex.uScale = s / a,
             this._tex.vScale = -1,
@@ -40,7 +40,7 @@ export default class XDecalMaterial {
             this._mat.backFaceCulling = !1,
             this._mat.transparencyMode = BABYLON.Material.MATERIAL_ALPHATEST,
             c != null && c.dispose(),
-            l(!0)) : !r && t && typeof e == "string" ? this._tex = new BABYLON.Texture(e,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
+            l(!0)) : !r && t && typeof e == "string" ? this._tex = new BABYLON.Texture(e,this.scene,!0,!1,BABYLON.Texture.BILINEAR_SAMPLINGMODE,()=>{
                 this._tex.name = "decal_" + this._id,
                 this._mat.emissiveTexture = this._tex,
                 this._mat.diffuseTexture = this._tex,
@@ -54,7 +54,7 @@ export default class XDecalMaterial {
                 logger.error("[Engine] decal create texture error!"),
                 u(new XDecalTextureError("[Engine] decal create texture error!"))
             }
-            ,null,!0) : this._tex = new Texture("data:decal_" + this._id,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
+            ,null,!0) : this._tex = new BABYLON.Texture("data:decal_" + this._id,this.scene,!0,!1,BABYLON.Texture.BILINEAR_SAMPLINGMODE,()=>{
                 this._tex.name = "decal_" + this._id,
                 this._mat.emissiveTexture = this._tex,
                 this._mat.diffuseTexture = this._tex,
@@ -73,7 +73,7 @@ export default class XDecalMaterial {
         ));
         this._id = e,
         this.scene = t,
-        this._mat = new StandardMaterial("decalMat_" + this._id,this.scene),
+        this._mat = new BABYLON.StandardMaterial("decalMat_" + this._id,this.scene),
         this._isRegisterAnimation = !1,
         this._uOffsetObserverable = new Observable
     }

+ 143 - 750
src/XSequence.js

@@ -1,168 +1,80 @@
-class XSubSequence {
-    constructor(e, t, r=DefaultUrlTransformer$1) {
+import {http2} from "./Http2.js"
+import XSubSequence from "./XSubSequence.js"
+
+const DefaultUrlTransformer = async i=>typeof i != "string" ? (console.warn("url transformer error", i),
+i) : i.startsWith("blob:") ? i : http2.get({
+    url: i,
+    useIndexedDb: !0,
+    key: "url"
+});
+
+export default class XSequence {
+    constructor(e, t, r="test", n=DefaultUrlTransformer) {
         E(this, "_scene");
-        E(this, "_meshGroups");
+        E(this, "_name");
+        E(this, "_subSeqs");
         E(this, "_animGroup");
-        E(this, "_particleGroups");
-        E(this, "_materialGroups");
-        E(this, "_spriteGroups");
-        E(this, "_glowGroups");
-        E(this, "_highLightGroups");
-        E(this, "_endFrame");
-        E(this, "_centerNode");
-        E(this, "_rootDir");
+        E(this, "_targetSubSeqs");
         E(this, "_abosoluteUrl");
-        E(this, "_name");
-        E(this, "_pickable", !1);
+        E(this, "_rootDir");
         E(this, "urlTransformer");
-        E(this, "onLoadedObserverable", new Observable);
-        E(this, "onSubSequenceTransformationChangeObservable", new Observable);
-        E(this, "onIntersectionObservable", new Observable);
-        E(this, "_loaded");
-        E(this, "_isStarted");
-        E(this, "_isPaused");
-        E(this, "_isDisposing", !1);
-        E(this, "init", ()=>new Promise((e,t)=>{
-            this.urlTransformer(this._abosoluteUrl).then(r=>{
-                const n = new XMLHttpRequest;
-                n.open("get", r),
-                n.send(null),
-                n.onload = ()=>{
-                    if (n.status == 200) {
-                        const o = JSON.parse(n.responseText);
-                        this.load(o).then(()=>{
-                            this.onLoadedObserverable.notifyObservers(this),
-                            this._loaded = !0,
+        E(this, "init", async()=>new Promise(e=>{
+            this.urlTransformer(this._abosoluteUrl).then(t=>{
+                const r = new XMLHttpRequest;
+                r.open("get", t),
+                r.send(null),
+                r.onload = ()=>{
+                    if (r.status == 200) {
+                        const n = JSON.parse(r.responseText);
+                        this.load(n).then(()=>{
                             e()
                         }
-                        , ()=>{
-                            t(),
-                            log$A.error("subSequence: Load ${jsonBlob} json fail")
-                        }
                         )
                     }
                 }
-                ,
-                n.onerror = ()=>{
-                    log$A.error("http: Get ${jsonBlob} json fail"),
-                    t()
-                }
             }
             )
         }
         ));
-        E(this, "play", async(e=!0)=>new Promise(t=>{
-            if (this._animGroup.isPlaying && this._animGroup.stop(),
-            this._particleGroups.forEach(r=>{
-                var n;
-                ((n = r.emitterNode) == null ? void 0 : n.getClassName()) == "Mesh" && r.emitterNode instanceof Mesh ? r.emitterNode.isEnabled() && r.start() : r.start()
+        E(this, "getRootOfSubSeqs", ()=>{
+            const e = new Array;
+            return this._subSeqs.forEach(t=>{
+                e.push(t.root)
             }
             ),
-            this._animGroup.targetedAnimations.length == 0) {
-                this.show();
-                let r = 0;
-                this._spriteGroups.forEach(n=>{
-                    n.sprites.forEach(o=>{
-                        o.toIndex > r && (r = o.toIndex)
-                    }
-                    )
-                }
-                ),
-                this._spriteGroups.forEach(n=>{
-                    n.sprites.forEach(o=>{
-                        o.playAnimation(o.fromIndex, o.toIndex, e, o.delay, ()=>{
-                            o.toIndex == r && (this._isPaused = !0,
-                            this.hide(),
-                            t())
-                        }
-                        )
-                    }
-                    )
-                }
-                )
-            } else
-                this._animGroup.play(e),
-                this._spriteGroups.forEach(r=>{
-                    r.sprites.forEach(n=>{
-                        n.playAnimation(n.fromIndex, n.toIndex, e, n.delay)
-                    }
-                    )
-                }
-                ),
-                e ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
-                    t()
-                }
-                ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
-                    this._spriteGroups.forEach(r=>{
-                        r.sprites.forEach(n=>{
-                            n.isVisible = !1,
-                            n.isPickable = !1,
-                            n.stopAnimation()
-                        }
-                        )
-                    }
-                    ),
-                    t()
-                }
-                );
-            this._isStarted = !0,
-            this._isPaused = !1
+            e
         }
-        ));
-        E(this, "stop", ()=>{
-            this._animGroup.stop(),
-            this._particleGroups.forEach(e=>{
-                e.systems.forEach(t=>{
-                    t.stop()
-                }
-                )
+        );
+        E(this, "play", async(e=!0)=>new Promise(t=>{
+            this._animGroup.play(e),
+            e ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
+                t()
             }
-            ),
-            this._spriteGroups.forEach(e=>{
-                e.sprites.forEach(t=>{
-                    t.stopAnimation()
-                }
-                )
+            ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
+                t()
             }
-            ),
-            this._isStarted = !1
+            )
+        }
+        ));
+        E(this, "goToFrame", e=>{
+            this._animGroup.goToFrame(e)
         }
         );
-        E(this, "clone", (e="Clone")=>{
-            const t = new XSubSequence(this._scene,this._abosoluteUrl);
-            return t._centerNode.name = e + "_" + this._centerNode.name,
-            t._animGroup.name = e + "_" + this._animGroup.name,
-            this._meshGroups.forEach(r=>{
-                const n = r.clone(e + "_", t._centerNode)
-                  , o = n.getChildren(void 0, !1);
-                if (o.forEach(a=>{
-                    a.setEnabled(!0)
-                }
-                ),
-                o.push(n),
-                n) {
-                    const a = r.getChildren(void 0, !1);
-                    a.push(r),
-                    this.animGroup.targetedAnimations.forEach(s=>{
-                        if (s.target instanceof Node$2) {
-                            const l = a.indexOf(s.target);
-                            l != -1 && t._animGroup.addTargetedAnimation(s.animation, o[l])
-                        }
-                    }
-                    )
-                }
+        E(this, "hide", ()=>{
+            this._subSeqs.forEach(e=>{
+                e.hide()
             }
-            ),
-            t._loaded = !0,
-            t
+            )
         }
         );
-        E(this, "goToFrame", e=>{
-            this._animGroup.start(!0, 1, e, e)
+        E(this, "show", ()=>{
+            this._subSeqs.forEach(e=>{
+                e.show()
+            }
+            )
         }
         );
         E(this, "pause", ()=>{
-            this._isPaused = !0,
             this._animGroup.pause()
         }
         );
@@ -170,656 +82,137 @@ class XSubSequence {
             this._animGroup.reset()
         }
         );
-        E(this, "loadTrackToAnim", e=>{
-            const t = Array();
-            let r = !0;
-            e.keyFrame.forEach(o=>{
-                if (o.frame > this._endFrame && (this._endFrame = o.frame),
-                o.value instanceof Array) {
-                    const a = {
-                        frame: o.frame,
-                        value: new BABYLON.Vector3(0,0,0)
-                    }
-                      , s = new BABYLON.Vector3(o.value[0],o.value[1],o.value[2]);
-                    a.value = s,
-                    t.push(a)
-                } else
-                    t.push(o),
-                    r = !1
-            }
-            ),
-            e.loop == null && (e.loop = !1),
-            e.index == null && (e.index = 0);
-            let n = null;
-            if ("blockName"in e) {
-                const o = {
-                    keyFrame: t,
-                    blockName: e.blockName,
-                    property: e.property,
-                    targetName: e.targetName,
-                    index: e.index,
-                    loop: e.loop
-                };
-                n = this.transferTrackToAnim(o, r)
-            } else {
-                const o = {
-                    keyFrame: t,
-                    property: e.property,
-                    targetName: e.targetName,
-                    index: e.index,
-                    loop: e.loop
-                };
-                n = this.transferTrackToAnim(o, r)
-            }
-            return n
-        }
-        );
-        E(this, "transferTrackToAnim", (e,t)=>{
-            let r = null;
-            t ? (r = new Animation(e.targetName + "_" + e.property,e.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CYCLE),
-            r.setKeys(e.keyFrame)) : (r = new Animation(e.targetName + "_" + e.property,e.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE),
-            r.setKeys(e.keyFrame));
-            let n = null;
-            return "blockName"in e ? n = {
-                animation: r,
-                blockName: e.blockName,
-                targetName: e.targetName,
-                nodeIndex: e.index,
-                loop: e.loop
-            } : n = {
-                animation: r,
-                targetName: e.targetName,
-                nodeIndex: e.index,
-                loop: e.loop
-            },
-            n
-        }
-        );
-        t.indexOf("./") == 0 && (t = t.slice(2)),
+        this._scene = e,
         this._abosoluteUrl = t,
-        this._name = t.split("/").slice(-1)[0].split(".")[0].split("_")[1],
         this._rootDir = t.split("/").slice(0, -1).join("/") + "/",
-        this._scene = e,
-        this._meshGroups = new Map,
-        this._animGroup = new AnimationGroup("SubSeqAnim_",this._scene),
-        this._particleGroups = new Map,
-        this._materialGroups = new Map,
-        this._glowGroups = new Map,
-        this._highLightGroups = new Map,
-        this._spriteGroups = new Map,
-        this._endFrame = 0,
-        this._centerNode = new TransformNode("__rootSubSeq__",e),
-        this._loaded = !1,
-        this._isPaused = !0,
-        this._isStarted = !1,
-        this._centerNode.setEnabled(!1),
-        this.urlTransformer = r,
-        this._centerNode.onAfterWorldMatrixUpdateObservable.add(()=>{
-            this.onSubSequenceTransformationChangeObservable.notifyObservers(this)
-        }
-        ),
+        this._name = r,
+        this._subSeqs = new Map,
+        this._animGroup = new BABYLON.AnimationGroup("Seq_" + r,e),
+        this._targetSubSeqs = new Map,
         this._animGroup.onAnimationGroupPlayObservable.add(()=>{
-            this._particleGroups.forEach(n=>{
-                n.systems.forEach(o=>{
-                    o.isStarted() || o.start()
-                }
-                )
-            }
-            ),
-            this.show()
-        }
-        ),
-        this._animGroup.onAnimationGroupLoopObservable.add(()=>{
-            this._particleGroups.forEach(n=>{
-                n.systems.forEach(o=>{
-                    o.isStarted() || o.start()
-                }
-                )
+            this._subSeqs.forEach(o=>{
+                o.show()
             }
-            ),
-            this.show()
+            )
         }
         ),
         this._animGroup.onAnimationGroupEndObservable.add(()=>{
-            this.hide()
-        }
-        )
-    }
-    dispose() {
-        this._isDisposing = !0,
-        this._spriteGroups.forEach(e=>{
-            e.dispose()
-        }
-        ),
-        this._glowGroups.forEach(e=>{
-            e.dispose()
-        }
-        ),
-        this._highLightGroups.forEach(e=>{
-            e.dispose()
-        }
-        ),
-        this._particleGroups.forEach(e=>{
-            XParticleManager.disposeParticleSysSet(e)
-        }
-        ),
-        this._animGroup.stop(),
-        this._animGroup.dispose(),
-        this._meshGroups.forEach(e=>{
-            e.getChildren(void 0, !1).forEach(t=>{
-                var r, n;
-                (t.getClassName() === "AbstractMesh" || t.getClassName() === "Mesh") && ((r = t.skeleton) == null || r.dispose(),
-                (n = t.material) == null || n.dispose(!0, !0)),
-                t.dispose(!0, !0)
+            this._subSeqs.forEach(o=>{
+                o.hide()
             }
-            ),
-            e.dispose(!1, !0)
+            )
         }
         ),
-        this._centerNode.dispose(!1, !0),
-        this._materialGroups.forEach(e=>{}
-        ),
-        this._materialGroups.clear(),
-        this._spriteGroups.clear(),
-        this._glowGroups.clear(),
-        this._highLightGroups.clear(),
-        this._meshGroups.clear(),
-        this._particleGroups.clear(),
-        this._loaded = !1
+        this.urlTransformer = n
     }
     get animGroup() {
         return this._animGroup
     }
-    get name() {
-        return this._name
-    }
-    get path() {
-        return this._abosoluteUrl
-    }
-    get position() {
-        return xversePosition2Ue4(this.pos)
-    }
-    get rotation() {
-        return xverseRotation2Ue4(this.rot)
-    }
-    get scaling() {
-        return this.scal
-    }
-    get pos() {
-        return this._centerNode.position
-    }
-    get rot() {
-        return this._centerNode.rotation
-    }
-    get scal() {
-        return this._centerNode.scaling
-    }
-    get root() {
-        return this._centerNode
-    }
-    get loaded() {
-        return this._loaded
+    serialize() {
+        const e = {};
+        return e.SubSequence = new Array,
+        e.TimeLine = new Array,
+        this._subSeqs.forEach(t=>{
+            const r = {
+                name: t.name,
+                uri: t.path
+            };
+            e.SubSequence.push(r);
+            const n = this._targetSubSeqs.get(t);
+            n && e.TimeLine.push({
+                frame: n == null ? void 0 : n.frame,
+                position: n.position,
+                rotation: n.rotation,
+                scaling: n.scaling,
+                name: t.name
+            })
+        }
+        ),
+        e
     }
     get isPlaying() {
-        return this._animGroup ? this._animGroup.isPlaying : this._isStarted && !this._isPaused
+        return this._animGroup.isPlaying
     }
     get isStarted() {
-        return this._animGroup ? this._animGroup.isStarted : this._isStarted
+        return this._animGroup.isStarted
     }
-    get isPickable() {
-        return this._pickable
-    }
-    set isPickable(e) {
-        this._meshGroups.forEach(t=>{
-            t.getChildMeshes().forEach(r=>{
-                r.isPickable = e
-            }
-            )
-        }
-        ),
-        this._spriteGroups.forEach(t=>{
-            t.isPickable = e,
-            t.sprites.forEach(r=>{
-                r.isPickable = e
-            }
-            )
+    get loaded() {
+        let e = !0;
+        return this._subSeqs.forEach(t=>{
+            e = e && t.loaded
         }
         ),
-        this._pickable = e
-    }
-    addAnimation(e) {
-        this._animGroup.addTargetedAnimation(e, this._centerNode),
-        this._spriteGroups.forEach(t=>{
-            t.sprites.forEach(r=>{
-                this._animGroup.addTargetedAnimation(e, r)
-            }
-            )
-        }
-        )
+        e
     }
-    setStartFrame(e) {
-        this._animGroup.stop(),
-        this._animGroup.targetedAnimations.forEach(t=>{
-            const r = t.animation.getKeys();
-            r.forEach(n=>{
-                e + r[0].frame > 0 ? n.frame += e : n.frame -= r[0].frame
-            }
-            )
-        }
-        )
-    }
-    lookAt(e) {
-        ue4Position2Xverse(e) && this.root.lookAt(ue4Position2Xverse(e))
-    }
-    setPosition(e) {
-        this.setPositionVector(ue4Position2Xverse(e))
-    }
-    setPositionVector(e) {
-        this._centerNode.position = e,
-        this._particleGroups.forEach(t=>{
-            t.emitterNode == null || t.emitterNode instanceof BABYLON.Vector3 ? t.emitterNode = e : this._scene.getMeshByName(t.emitterNode.name) || (t.emitterNode = e)
+    dispose() {
+        this._subSeqs.forEach(e=>{
+            e.dispose()
         }
         ),
-        this._spriteGroups.forEach(t=>{
-            t.sprites.forEach((r,n)=>{
-                r.position = e
-            }
-            )
-        }
-        )
-    }
-    setScaling(e) {
-        this.setScalingVector(ue4Scaling2Xverse(e))
+        this.animGroup.dispose()
     }
-    setScalingVector(e) {
-        var t;
-        this._centerNode.scaling = e,
-        (t = this._particleGroups) == null || t.forEach(r=>{
-            r.systems.forEach(n=>{
-                XParticleManager.scalingInPlace(n, e.x)
-            }
-            )
+    setFrame(e, t) {
+        const r = this._subSeqs.get(e);
+        if (r) {
+            const n = this._targetSubSeqs.get(r);
+            n && (n.frame = t),
+            n && this.update(r, n)
         }
-        ),
-        this._spriteGroups.forEach(r=>{
-            r.sprites.forEach(n=>{
-                n.size *= e.x
-            }
-            )
-        }
-        )
     }
-    setRotation(e) {
-        this.setRotationVector(ue4Rotation2Xverse(e))
-    }
-    setRotationVector(e) {
-        this._centerNode.rotation = e
+    get name() {
+        return this._name
     }
-    hide() {
-        this._centerNode.setEnabled(!1),
-        this._particleGroups.forEach(e=>{
-            e.systems.forEach(t=>{
-                t.isStarted() && t.stop()
-            }
-            )
+    update(e, t) {
+        if (t) {
+            const r = {
+                frame: t.frame,
+                scaling: new BABYLON.Vector3(t.scaling[0],t.scaling[1],t.scaling[2]),
+                position: new BABYLON.Vector3(t.position[0],t.position[1],t.position[2]),
+                rotation: new BABYLON.Vector3(t.rotation[0] / 180 * Math.PI,t.rotation[1] / 180 * Math.PI,t.rotation[2] / 180 * Math.PI),
+                name: t.name
+            }
+              , n = this._subSeqs.get(r.name);
+            n && (n.setPositionVector(r.position),
+            n.setRotationVector(r.rotation),
+            n.setScalingVector(r.scaling),
+            n.setStartFrame(r.frame),
+            this._targetSubSeqs.set(n, t),
+            n.onSubSequenceTransformationChangeObservable.add(()=>{
+                const o = this._targetSubSeqs.get(n);
+                o && (o.position = [n.pos.x, n.pos.y, n.pos.z]),
+                o && (o.rotation = [n.rot.x, n.rot.y, n.rot.z]),
+                o && (o.scaling = [n.scal.x, n.scal.y, n.scal.z])
+            }
+            ))
         }
-        ),
-        this._spriteGroups.forEach(e=>{
-            e.sprites.forEach(t=>{
-                t.isVisible = !1
-            }
-            )
-        }
-        )
-    }
-    show() {
-        this._centerNode.setEnabled(!0),
-        this._centerNode.getChildren().forEach(e=>{
-            e.setEnabled(!0),
-            e.getChildMeshes().forEach(t=>{
-                t.setEnabled(!0)
-            }
-            )
-        }
-        ),
-        this._particleGroups.forEach(e=>{
-            e.systems.forEach(t=>{
-                t.start()
-            }
-            )
-        }
-        ),
-        this._spriteGroups.forEach(e=>{
-            e.sprites.forEach(t=>{
-                t.isVisible = !0
-            }
-            )
-        }
-        )
-    }
-    get totalFrame() {
-        return this._endFrame
     }
     load(e) {
         return new Promise((t,r)=>{
-            const n = e.Mesh
-              , o = e.Sprite
-              , a = e.Material
-              , s = e.Glow
-              , l = e.HighLight
-              , u = e.Particle
-              , c = e.MeshTrack
-              , h = e.ParticleTrack
-              , f = e.MaterialTrack;
-            this._animGroup.name += e.Type;
-            const d = Date.now();
-            this._centerNode.name += e.Type;
-            const _ = new Array
-              , g = new Array;
-            n != null && n.forEach(m=>{
-                _.push(this.loadMesh(m))
-            }
-            ),
-            o != null && o.forEach(m=>{
-                g.push(this.loadSprite(m))
-            }
-            ),
-            Promise.all(_).then(()=>{
-                a != null && a.forEach(m=>{
-                    g.push(this.loadMaterial(m))
-                }
-                ),
-                u != null && u.forEach(m=>{
-                    g.push(this.loadParticle(m))
+            const n = new Array
+              , o = e.SubSequence
+              , a = e.TimeLine;
+            for (const s of o) {
+                s.uri.indexOf("./") == 0 && (s.uri = s.uri.slice(2));
+                const l = new XSubSequence(this._scene,this._rootDir + s.uri,this.urlTransformer);
+                this._subSeqs.set(s.name, l),
+                n.push(l.init())
+            }
+            Promise.all(n).then(()=>{
+                a.forEach(s=>{
+                    const l = this._subSeqs.get(s.name);
+                    l && this.update(l, s)
                 }
                 ),
-                Promise.all(g).then(()=>{
-                    if (this._isDisposing) {
-                        const v = Date.now() - d;
-                        log$A.info(`subSequence: Load ${e.Type} takes ${v} ms`),
-                        t(this);
-                        return
-                    }
-                    if (s != null)
-                        for (const v of s)
-                            this.loadGlow(v);
-                    if (l != null)
-                        for (const v of l)
-                            this.loadHighLight(v);
-                    c != null && c.forEach(v=>{
-                        const y = this._meshGroups.get(v.targetName);
-                        if (y != null) {
-                            const b = this.loadTrackToAnim(v);
-                            ROOT_MESH_ANIM_PROPERTY.indexOf(b.animation.targetProperty) == -1 ? y.getChildMeshes().forEach(T=>{
-                                b.animation.targetProperty in T && this._animGroup.addTargetedAnimation(b.animation, T)
-                            }
-                            ) : this._animGroup.addTargetedAnimation(b.animation, y)
-                        }
-                    }
-                    ),
-                    h != null && h.forEach(v=>{
-                        var C;
-                        const y = v.index
-                          , b = v.targetName
-                          , T = (C = this._particleGroups.get(b)) == null ? void 0 : C.systems[y];
-                        if (T != null) {
-                            const A = this.loadTrackToAnim(v);
-                            this._animGroup.addTargetedAnimation(A.animation, T)
-                        }
-                    }
-                    ),
-                    f != null && f.forEach(v=>{
-                        const y = this._materialGroups.get(v.targetName);
-                        if (y) {
-                            const b = y[0];
-                            if (b != null)
-                                if (b.getBlockByName(v.blockName) != null) {
-                                    const T = this.loadTrackToAnim(v);
-                                    y == null || y.forEach(C=>{
-                                        this._animGroup.addTargetedAnimation(T.animation, C.getBlockByName(v.blockName))
-                                    }
-                                    )
-                                } else
-                                    console.error("property " + v.property + "is not in " + b.name)
-                        }
-                    }
-                    );
-                    const m = Date.now() - d;
-                    log$A.info(`subSequence: Load ${e.Type} takes ${m} ms`),
-                    t(this)
-                }
-                , ()=>{
-                    log$A.error(`subSequence: Load ${e.Type} fail`),
-                    r()
-                }
-                )
-            }
-            , ()=>{
-                r()
-            }
-            )
-        }
-        )
-    }
-    loadMesh(e) {
-        return new Promise((t,r)=>{
-            const n = this._rootDir + e.uri;
-            this.urlTransformer(n).then(o=>{
-                if (this._isDisposing) {
-                    t();
-                    return
-                }
-                BABYLON.SceneLoader.LoadAssetContainer("", o, this._scene, a=>{
-                    if (this._isDisposing) {
-                        a.removeAllFromScene(),
-                        t();
-                        return
-                    }
-                    a.animationGroups.forEach(l=>{
-                        l.stop()
-                    }
-                    ),
-                    a.animationGroups.length != 0 && (a.animationGroups.forEach(l=>{
-                        l.targetedAnimations.forEach(u=>{
-                            this._animGroup.addTargetedAnimation(u.animation, u.target)
-                        }
-                        ),
-                        l.dispose()
-                    }
-                    ),
-                    a.animationGroups = [],
-                    a.animations = [],
-                    a.materials = []);
-                    const s = new TransformNode("__root__" + e.name,this._scene);
-                    if (e.uri.split(".")[1] == "glb")
-                        a.meshes[0].parent = s;
-                    else if (e.uri.split(".")[1] == "obj") {
-                        const l = new TransformNode("__root__",this._scene);
-                        a.meshes.forEach(u=>{
-                            u.parent = l,
-                            u.Type = MESH_TAG
-                        }
-                        ),
-                        l.parent = s
-                    }
-                    s.getChildMeshes().forEach(l=>{
-                        e.isPickable != null ? l.isPickable = e.isPickable : l.isPickable = !1,
-                        l.xtype = "XSubSequence"
-                    }
-                    ),
-                    this._meshGroups.set(e.name, s),
-                    s.parent = this._centerNode,
-                    a.addAllToScene(),
-                    t()
-                }
-                , ()=>{}
-                , ()=>{
-                    log$A.error("subSequence:Load effect mesh fail"),
-                    log$A.error(`Effect Mesh ${e.name} load error`),
-                    r()
-                }
-                , ".glb")
-            }
-            , ()=>{
-                log$A.error("http:Get effect mesh fail"),
-                log$A.error(`Effect Mesh ${e.name} load error`),
-                r()
-            }
-            )
-        }
-        )
-    }
-    loadSprite(e) {
-        return new Promise((t,r)=>{
-            if (this._isDisposing) {
-                t();
-                return
-            }
-            const n = this._rootDir + e.uri;
-            if (e.uri !== "") {
-                e.name;
-                const o = new XMLHttpRequest;
-                o.open("get", n),
-                o.send(null),
-                o.onload = ()=>{
-                    if (o.status == 200) {
-                        const a = JSON.parse(o.responseText)
-                          , s = XSpriteManager.Parse(a, this._scene, this._rootDir);
-                        s.sprites.forEach(l=>{
-                            l.stopAnimation()
-                        }
-                        ),
-                        this._spriteGroups.set(e.name, s),
-                        t()
-                    } else
-                        log$A.error("subSequence:Load effect sprite fail"),
-                        log$A.error(`Effect Sprite ${e.name} load error`),
-                        r()
-                }
-            }
-        }
-        )
-    }
-    loadMaterial(e) {
-        return new Promise((t,r)=>{
-            if (this._isDisposing) {
-                t();
-                return
-            }
-            const n = this._rootDir + e.uri;
-            if (e.uri !== "") {
-                const o = e.name
-                  , a = new NodeMaterial(`material_${o}`,this._scene,{
-                    emitComments: !1
-                });
-                a.backFaceCulling = !1,
-                this.urlTransformer(n).then(s=>{
-                    if (this._isDisposing) {
-                        a.dispose(!1, !0, !1),
-                        t();
-                        return
-                    }
-                    a.loadAsync(s).then(()=>{
-                        if (this._isDisposing) {
-                            a.dispose(!0, !0, !1),
-                            t();
-                            return
-                        }
-                        a.build(!1);
-                        const l = new Array;
-                        let u = !1;
-                        for (let c = 0; c < e.meshName.length; c++)
-                            this._meshGroups.forEach(h=>{
-                                h.getChildMeshes().forEach(f=>{
-                                    var d;
-                                    if (f.name === e.meshName[c]) {
-                                        u = !0,
-                                        (d = f.material) == null || d.dispose(!0, !0);
-                                        const _ = f;
-                                        if (_.skeleton == null) {
-                                            const g = a;
-                                            _.material = g,
-                                            l.push(g)
-                                        } else if (_.numBoneInfluencers = 4,
-                                        _.computeBonesUsingShaders = !0,
-                                        c == 0) {
-                                            const g = a;
-                                            _.material = g,
-                                            l.push(g)
-                                        } else {
-                                            const g = a.clone(`material_${o}` + String(c), !1);
-                                            _.material = g,
-                                            l.push(g)
-                                        }
-                                    }
-                                }
-                                )
-                            }
-                            );
-                        u ? this._materialGroups.set(e.name, l) : a.dispose(!0, !0),
-                        t()
-                    }
-                    , ()=>{
-                        log$A.error("http:Get effect Material fail"),
-                        log$A.error(`Effect NodeMaterial ${o} load error`),
-                        r()
+                this._subSeqs.forEach(s=>{
+                    s.animGroup.targetedAnimations.forEach(l=>{
+                        this._animGroup.addTargetedAnimation(l.animation, l.target)
                     }
                     )
                 }
-                )
-            }
-        }
-        )
-    }
-    async loadGlow(e) {
-        const t = new GlowLayer(e.name,this._scene,{
-            blurKernelSize: e.blurKernelSize
-        });
-        t.intensity = e.intensity,
-        e.meshName.forEach(r=>{
-            const n = this._scene.getMeshByName(r);
-            n != null && t.addIncludedOnlyMesh(n)
-        }
-        ),
-        this._glowGroups.set(e.name, t)
-    }
-    loadHighLight(e) {
-        const t = new HighlightLayer(e.name,this._scene);
-        e.meshName.forEach(r=>{
-            const n = this._scene.getMeshByName(r);
-            if (n != null) {
-                const o = new BABYLON.Color3(e.color[0],e.color[1],e.color[2]);
-                t.addMesh(n, o)
-            }
-        }
-        ),
-        this._highLightGroups.set(e.name, t)
-    }
-    loadParticle(e) {
-        return new Promise((t,r)=>{
-            const n = this._rootDir + e.rootDir
-              , o = new XParticleManager(this._scene);
-            this.urlTransformer(n + e.uri).then(a=>{
-                if (this._isDisposing) {
-                    t();
-                    return
-                }
-                o.load(n, e.uri, e.name).then(s=>{
-                    if (this._isDisposing) {
-                        r();
-                        return
-                    }
-                    this._particleGroups.set(e.name, s),
-                    t()
-                }
-                , ()=>{
-                    log$A.error(`SubSequence: ${e.name} particle load fail`),
-                    r()
-                }
-                )
+                ),
+                t()
             }
             , ()=>{
-                log$A.error(`http: ${n + e.uri} load fail`),
                 r()
             }
             )

+ 1 - 1
src/XSpriteManager.js

@@ -17,7 +17,7 @@ class XSpriteManager extends SpriteManager {
             width: e.cellWidth,
             height: e.cellHeight
         },t);
-        e.texture ? n.texture = Texture.Parse(e.texture, t, r) : e.textureName && (n.texture = new Texture(r + e.textureUrl,t,!0,e.invertY !== void 0 ? e.invertY : !0));
+        e.texture ? n.texture = BABYLON.Texture.Parse(e.texture, t, r) : e.textureName && (n.texture = new BABYLON.Texture(r + e.textureUrl,t,!0,e.invertY !== void 0 ? e.invertY : !0));
         for (const o of e.sprites) {
             const a = Sprite.Parse(o, n);
             n.originalPositions.push(a.position)

+ 1 - 1
src/XStateMachine.js

@@ -1,7 +1,7 @@
 //const log$G = new Logger$1("XStateMachine");
 import {logger} from "./Logger.js"
 
-class XStateMachine {
+export default class XStateMachine {
     constructor(e) {
         E(this, "state");
         E(this, "isMoving");

+ 1 - 1
src/XTelevision.js

@@ -179,7 +179,7 @@ export default class XTelevision {
             this.videoMat.setFloat("mvWidthHeightScale", 16 / 9),
             this.videoMat.setFloat("bforceforceKeepContent", -1),
             this.videoMat.backFaceCulling = !1,
-            this.videoMat.sideOrientation = Mesh.FRONTSIDE,
+            this.videoMat.sideOrientation = BABYLON.Mesh.FRONTSIDE,
             this.videoElement.addEventListener("loadedmetadata", u=>{
                 this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
             }

+ 5 - 1
src/XverseAvatar.js

@@ -2,6 +2,10 @@
 import {logger} from "./Logger.js"
 import util from "./util.js"
 import InternalError from "./error/InternalError.js"
+import EAvatarRelationRank from "./enum/EAvatarRelationRank.js"
+import AvatarGroup from "./enum/AvatarGroup.js"
+import MotionType from "./enum/MotionType.js"
+import Queue from "./Queue.js"
 
 export default class XverseAvatar extends EventEmitter {
     constructor({userId: e, isHost: t, room: r, avatarId: n, isSelf: o, group: a=AvatarGroup.Npc}) {
@@ -350,7 +354,7 @@ export default class XverseAvatar extends EventEmitter {
             return logger.warn(a),
             Promise.reject(new ParamError(a))
         }
-        const o = getDistance(this.position, t) / 100 > 100 ? MotionType.Run : MotionType.Walk;
+        const o = util.getDistance(this.position, t) / 100 > 100 ? MotionType.Run : MotionType.Walk;
         return this._room.actionsHandler.moveTo({
             point: t,
             motionType: o,

+ 12 - 5
src/XverseAvatarManager.js

@@ -3,8 +3,14 @@ import {logger} from "./Logger.js"
 import CoreBroadcastType from "./enum/CoreBroadcastType.js"
 import AvatarGroup from "./enum/AvatarGroup.js"
 import Broadcast from "./Broadcast.js"
-import TimeoutError from "./error/TimeoutError.js"
 import {avatarLoader} from "./XAvatarLoader.js"
+import SyncEventType from "./enum/SyncEventType.js"
+import GetStateTypes from "./enum/GetStateTypes.js"
+import EAvatarRelationRank from "./enum/EAvatarRelationRank.js"
+import Person from "./enum/Person.js"
+import XverseAvatar from "./XverseAvatar.js"
+import MotionType from "./enum/MotionType.js"
+import TimeoutError from "./error/TimeoutError.js"
 
 export default class XverseAvatarManager extends EventEmitter {
     constructor(e) {
@@ -207,7 +213,7 @@ export default class XverseAvatarManager extends EventEmitter {
         let g = this.avatars.get(t);
         if (g)
             return Promise.resolve(g);
-        if (g = new xe.subAvatar({
+        if (g = new XverseAvatarManager.subAvatar({
             userId: t,
             isHost: r,
             isSelf: _,
@@ -248,7 +254,7 @@ export default class XverseAvatarManager extends EventEmitter {
                     avatarRotation: a,
                     avatarScale: h
                 }
-            })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
+            })._timeout(8e3, new TimeoutError("loadAvatar timeout(8s)"));
             return C.setPickBoxScale(t === this._room.userId ? 0 : 1),
             g.xAvatar = C,
             g.setScale(h),
@@ -364,5 +370,6 @@ export default class XverseAvatarManager extends EventEmitter {
         }
         )
     }
-}
-;
+};
+
+E(XverseAvatarManager, "subAvatar", XverseAvatar);

+ 1 - 0
src/Xverse_Room.js

@@ -24,6 +24,7 @@ import EngineProxy from "./EngineProxy.js"
 import EventsController from "./EventsController.js"
 import EImageQuality from "./enum/EImageQuality.js"
 import Panorama from "./Panorama.js"
+import Debug from "./Debug.js"
 
 export default class Xverse_Room extends EventEmitter {
     constructor(e) {

+ 12 - 11
src/main.js

@@ -28,7 +28,7 @@ const l = async()=>{
 
     try {
 
-        room = await xverse.joinRoom({
+        let room = await xverse.joinRoom({
             canvas: document.getElementById('canvas'),
             skinId: '10092',
             avatarId: 'KGe_Boy',
@@ -49,11 +49,12 @@ const l = async()=>{
             hasAvatar: !0,
             syncToOthers: !0
         });
-        debugger
+        window.room = room;
+
         u();
         c();
-        window.room = room;
-        e(!1);
+        
+        //e(!1);
     } catch (M) {
         console.error(M);
         alert(M);
@@ -62,8 +63,8 @@ const l = async()=>{
 }
 
 const u = ()=>{
-    room.on("_coreClick", ({point: f})=>{
-        room._userAvatar.moveTo({
+    window.room.on("_coreClick", ({point: f})=>{
+        window.room._userAvatar.moveTo({
             point: f
         })
     }
@@ -71,23 +72,23 @@ const u = ()=>{
 }
 
 const c = ()=>{
-    room.on("repeatLogin", function() {
+    window.room.on("repeatLogin", function() {
         toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
             duration: 1e4
         })
     }),
-    room.on("reconnecting", function({count: f}) {
+    window.room.on("reconnecting", function({count: f}) {
         toast(`\u5C1D\u8BD5\u7B2C${f}\u6B21\u91CD\u8FDE`)
     }),
-    room.on("reconnected", function() {
+    window.room.on("reconnected", function() {
         toast("\u91CD\u8FDE\u6210\u529F")
     }),
-    room.on("disconnected", function() {
+    window.room.on("disconnected", function() {
         const f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
             duration: 1e5,
             onClick() {
                 f.hideToast(),
-                room.reconnect()
+                window.room.reconnect()
             }
         })
     })

+ 5 - 0
src/util.js

@@ -96,6 +96,11 @@ var util = {
         const e = CodeErrorMap[i];
         return e || console.warn("unkown code", i),
         e || InternalError
+    },
+    getDistance(i, e) {
+        const {x: t, y: r, z: n} = i
+          , {x: o, y: a, z: s} = e;
+        return Math.sqrt(Math.abs(t - o) ** 2 + Math.abs(r - a) ** 2 + Math.abs(n - s) ** 2)
     }
 }
 export default util

File diff suppressed because it is too large
+ 0 - 136305
src/其他的js.txt


+ 126 - 1
src/开发笔记.txt

@@ -1,2 +1,127 @@
 1. Logger不能用单例模式,里面的module对应的是类的名称
-2. BABYLON
+2. BABYLON源码修改:
+
+          this._onBeforeRegisterBeforeRenderObserver = null,
+                this._onAfterRegisterBeforeRenderObserver = null,
+                this._RTT1Time = new Rr.a,
+                this._onBeforeRTT1Observer = null,
+                this._onAfterRTT1Observer = null,
+                this._registerAfterRenderTime = new Rr.a,
+                this._onBeforeRegisterAfterRenderObserver = null,
+                this._onAfterRegisterAfterRenderObserver = null,
+				
+				
+				
+				
+				
+				  this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
+                    t._registerBeforeRenderTime.beginMonitoring()
+                }),
+                this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
+                    t._registerBeforeRenderTime.endMonitoring()
+                }),
+                this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
+                    t._registerAfterRenderTime.beginMonitoring()
+                }),
+                this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
+                    t._registerAfterRenderTime.endMonitoring()
+                }),
+                this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
+                    t._RTT1Time.beginMonitoring()
+                }),
+                this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
+                    t._RTT1Time.endMonitoring()
+                })
+				
+				
+				
+				
+				
+				
+				
+				
+				 Object.defineProperty(e.prototype, "registerBeforeTimeCounter", {
+                get: function() {
+                    return this._registerBeforeRenderTime
+                },
+                enumerable: !1,
+                configurable: !0
+            }),
+            Object.defineProperty(e.prototype, "getRTT1TimeCounter", {
+                get: function() {
+                    return this._RTT1Time
+                },
+                enumerable: !1,
+                configurable: !0
+            }),
+            Object.defineProperty(e.prototype, "registerAfterTimeCounter", {
+                get: function() {
+                    return this._registerAfterRenderTime
+                },
+                enumerable: !1,
+                configurable: !0
+            }),
+			
+			
+			
+			
+			
+			
+			
+			        r.onBeforeRunRegisterBeforeRenderObservable = new Observable,
+        r.onAfterRunRegisterBeforeRenderObservable = new Observable,
+        r.onBeforeRunRegisterAfterRenderObservable = new Observable,
+        r.onAfterRunRegisterAfterRenderObservable = new Observable,
+        r.onBeforeRTT1Observable = new Observable,
+        r.onAfterRTT1Observable = new Observable,
+		
+		
+		
+		
+		
+		                    this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
+                    this.onBeforeRenderObservable.notifyObservers(this),
+                    this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
+					
+					
+					
+					
+					
+					
+					
+					
+					                    this.onBeforeRunRegisterBeforeRenderObservable.clear(),
+                    this.onAfterRunRegisterBeforeRenderObservable.clear(),
+                    this.onBeforeRTT1Observable.clear(),
+                    this.onAfterRTT1Observable.clear(),
+                    this.onBeforeRunRegisterAfterRenderObservable.clear(),
+                    this.onAfterRunRegisterAfterRenderObservable.clear()
+					
+					
+					
+					
+					
+					
+					
+					
+					        this.scene.onBeforeRunRegisterBeforeRenderObservable.remove(this._onBeforeRegisterBeforeRenderObserver),
+        this._onBeforeRegisterBeforeRenderObserver = null,
+        this.scene.onAfterRunRegisterBeforeRenderObservable.remove(this._onAfterRegisterBeforeRenderObserver),
+        this._onAfterRegisterBeforeRenderObserver = null,
+        this.scene.onBeforeRunRegisterAfterRenderObservable.remove(this._onBeforeRegisterAfterRenderObserver),
+        this._onBeforeRegisterAfterRenderObserver = null,
+        this.scene.onAfterRunRegisterAfterRenderObservable.remove(this._onAfterRegisterAfterRenderObserver),
+        this._onAfterRegisterAfterRenderObserver = null,
+        this.scene.onBeforeRTT1Observable.remove(this._onBeforeRTT1Observer),
+        this._onBeforeRTT1Observer = null,
+        this.scene.onAfterRTT1Observable.remove(this._onAfterRTT1Observer),
+        this._onAfterRTT1Observer = null,
+		
+		
+/***************************************************************************************************************************************************************************************/
+
+
+
+
+
+