spoint 0.1.0 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +134 -209
- package/SKILL.md +95 -0
- package/apps/environment/index.js +200 -1
- package/apps/environment/models/decorative/.gitkeep +0 -0
- package/apps/environment/models/hazards/.gitkeep +0 -0
- package/apps/environment/models/interactive/.gitkeep +0 -0
- package/apps/environment/models/structures/.gitkeep +0 -0
- package/apps/environment/smartObjects.js +114 -0
- package/apps/interactable/index.js +155 -0
- package/apps/physics-crate/index.js +15 -9
- package/apps/power-crate/index.js +18 -12
- package/apps/tps-game/$GDUPI.vrm +0 -0
- package/apps/tps-game/Cleetus.vrm +0 -0
- package/apps/tps-game/index.js +185 -27
- package/apps/world/index.js +68 -22
- package/bin/create-app.js +337 -0
- package/client/ARControls.js +301 -0
- package/client/LoadingManager.js +117 -0
- package/client/MobileControls.js +1122 -0
- package/client/anim-lib.glb +0 -0
- package/client/animation.js +306 -0
- package/client/app.js +1341 -65
- package/client/camera.js +191 -33
- package/client/createLoadingScreen.js +69 -0
- package/client/editor/bridge.js +113 -0
- package/client/editor/css/main.css +794 -0
- package/client/editor/images/rotate.svg +4 -0
- package/client/editor/images/scale.svg +4 -0
- package/client/editor/images/translate.svg +4 -0
- package/client/editor/index.html +103 -0
- package/client/editor/js/Command.js +41 -0
- package/client/editor/js/Config.js +81 -0
- package/client/editor/js/Editor.js +785 -0
- package/client/editor/js/EditorControls.js +438 -0
- package/client/editor/js/History.js +321 -0
- package/client/editor/js/Loader.js +987 -0
- package/client/editor/js/LoaderUtils.js +90 -0
- package/client/editor/js/Menubar.Add.js +510 -0
- package/client/editor/js/Menubar.Edit.js +145 -0
- package/client/editor/js/Menubar.File.js +466 -0
- package/client/editor/js/Menubar.Help.js +73 -0
- package/client/editor/js/Menubar.Status.js +51 -0
- package/client/editor/js/Menubar.View.js +183 -0
- package/client/editor/js/Menubar.js +27 -0
- package/client/editor/js/Player.js +53 -0
- package/client/editor/js/Resizer.js +58 -0
- package/client/editor/js/Script.js +503 -0
- package/client/editor/js/Selector.js +102 -0
- package/client/editor/js/Sidebar.Geometry.BoxGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.BufferGeometry.js +115 -0
- package/client/editor/js/Sidebar.Geometry.CapsuleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CircleGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.CylinderGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.DodecahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.ExtrudeGeometry.js +196 -0
- package/client/editor/js/Sidebar.Geometry.IcosahedronGeometry.js +73 -0
- package/client/editor/js/Sidebar.Geometry.LatheGeometry.js +98 -0
- package/client/editor/js/Sidebar.Geometry.Modifiers.js +73 -0
- package/client/editor/js/Sidebar.Geometry.OctahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.PlaneGeometry.js +97 -0
- package/client/editor/js/Sidebar.Geometry.RingGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.ShapeGeometry.js +76 -0
- package/client/editor/js/Sidebar.Geometry.SphereGeometry.js +133 -0
- package/client/editor/js/Sidebar.Geometry.TetrahedronGeometry.js +74 -0
- package/client/editor/js/Sidebar.Geometry.TorusGeometry.js +109 -0
- package/client/editor/js/Sidebar.Geometry.TorusKnotGeometry.js +121 -0
- package/client/editor/js/Sidebar.Geometry.TubeGeometry.js +135 -0
- package/client/editor/js/Sidebar.Geometry.js +332 -0
- package/client/editor/js/Sidebar.Material.BooleanProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.ColorProperty.js +87 -0
- package/client/editor/js/Sidebar.Material.ConstantProperty.js +62 -0
- package/client/editor/js/Sidebar.Material.MapProperty.js +249 -0
- package/client/editor/js/Sidebar.Material.NumberProperty.js +60 -0
- package/client/editor/js/Sidebar.Material.Program.js +73 -0
- package/client/editor/js/Sidebar.Material.RangeValueProperty.js +63 -0
- package/client/editor/js/Sidebar.Material.js +751 -0
- package/client/editor/js/Sidebar.Object.Animation.js +102 -0
- package/client/editor/js/Sidebar.Object.js +898 -0
- package/client/editor/js/Sidebar.Project.App.js +165 -0
- package/client/editor/js/Sidebar.Project.Image.js +225 -0
- package/client/editor/js/Sidebar.Project.Materials.js +82 -0
- package/client/editor/js/Sidebar.Project.Renderer.js +144 -0
- package/client/editor/js/Sidebar.Project.Video.js +242 -0
- package/client/editor/js/Sidebar.Project.js +31 -0
- package/client/editor/js/Sidebar.Properties.js +73 -0
- package/client/editor/js/Sidebar.Scene.js +585 -0
- package/client/editor/js/Sidebar.Script.js +129 -0
- package/client/editor/js/Sidebar.Settings.History.js +146 -0
- package/client/editor/js/Sidebar.Settings.Shortcuts.js +175 -0
- package/client/editor/js/Sidebar.Settings.js +60 -0
- package/client/editor/js/Sidebar.js +41 -0
- package/client/editor/js/Storage.js +98 -0
- package/client/editor/js/Strings.js +2028 -0
- package/client/editor/js/Toolbar.js +84 -0
- package/client/editor/js/Viewport.Controls.js +92 -0
- package/client/editor/js/Viewport.Info.js +136 -0
- package/client/editor/js/Viewport.Pathtracer.js +91 -0
- package/client/editor/js/Viewport.ViewHelper.js +39 -0
- package/client/editor/js/Viewport.XR.js +222 -0
- package/client/editor/js/Viewport.js +900 -0
- package/client/editor/js/commands/AddObjectCommand.js +68 -0
- package/client/editor/js/commands/AddScriptCommand.js +75 -0
- package/client/editor/js/commands/Commands.js +23 -0
- package/client/editor/js/commands/MoveObjectCommand.js +111 -0
- package/client/editor/js/commands/MultiCmdsCommand.js +85 -0
- package/client/editor/js/commands/RemoveObjectCommand.js +88 -0
- package/client/editor/js/commands/RemoveScriptCommand.js +81 -0
- package/client/editor/js/commands/SetColorCommand.js +73 -0
- package/client/editor/js/commands/SetGeometryCommand.js +87 -0
- package/client/editor/js/commands/SetGeometryValueCommand.js +70 -0
- package/client/editor/js/commands/SetMaterialColorCommand.js +86 -0
- package/client/editor/js/commands/SetMaterialCommand.js +79 -0
- package/client/editor/js/commands/SetMaterialMapCommand.js +143 -0
- package/client/editor/js/commands/SetMaterialRangeCommand.js +91 -0
- package/client/editor/js/commands/SetMaterialValueCommand.js +90 -0
- package/client/editor/js/commands/SetMaterialVectorCommand.js +79 -0
- package/client/editor/js/commands/SetPositionCommand.js +84 -0
- package/client/editor/js/commands/SetRotationCommand.js +84 -0
- package/client/editor/js/commands/SetScaleCommand.js +84 -0
- package/client/editor/js/commands/SetSceneCommand.js +103 -0
- package/client/editor/js/commands/SetScriptValueCommand.js +80 -0
- package/client/editor/js/commands/SetShadowValueCommand.js +73 -0
- package/client/editor/js/commands/SetUuidCommand.js +70 -0
- package/client/editor/js/commands/SetValueCommand.js +75 -0
- package/client/editor/js/libs/acorn/acorn.js +3236 -0
- package/client/editor/js/libs/acorn/acorn_loose.js +1299 -0
- package/client/editor/js/libs/acorn/walk.js +344 -0
- package/client/editor/js/libs/app/index.html +57 -0
- package/client/editor/js/libs/app.js +251 -0
- package/client/editor/js/libs/codemirror/addon/dialog.css +32 -0
- package/client/editor/js/libs/codemirror/addon/dialog.js +163 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.css +36 -0
- package/client/editor/js/libs/codemirror/addon/show-hint.js +529 -0
- package/client/editor/js/libs/codemirror/addon/tern.css +87 -0
- package/client/editor/js/libs/codemirror/addon/tern.js +750 -0
- package/client/editor/js/libs/codemirror/codemirror.css +344 -0
- package/client/editor/js/libs/codemirror/codemirror.js +9849 -0
- package/client/editor/js/libs/codemirror/mode/glsl.js +233 -0
- package/client/editor/js/libs/codemirror/mode/javascript.js +959 -0
- package/client/editor/js/libs/codemirror/theme/monokai.css +41 -0
- package/client/editor/js/libs/esprima.js +6401 -0
- package/client/editor/js/libs/jsonlint.js +453 -0
- package/client/editor/js/libs/signals.min.js +14 -0
- package/client/editor/js/libs/tern-threejs/threejs.js +5031 -0
- package/client/editor/js/libs/ternjs/comment.js +87 -0
- package/client/editor/js/libs/ternjs/def.js +588 -0
- package/client/editor/js/libs/ternjs/doc_comment.js +401 -0
- package/client/editor/js/libs/ternjs/infer.js +1635 -0
- package/client/editor/js/libs/ternjs/polyfill.js +80 -0
- package/client/editor/js/libs/ternjs/signal.js +26 -0
- package/client/editor/js/libs/ternjs/tern.js +993 -0
- package/client/editor/js/libs/ui.js +1346 -0
- package/client/editor/js/libs/ui.three.js +855 -0
- package/client/facial-animation.js +455 -0
- package/client/index.html +7 -4
- package/client/loading.css +147 -0
- package/client/loading.html +25 -0
- package/client/style.css +251 -0
- package/package.json +7 -3
- package/server.js +9 -1
- package/src/apps/AppContext.js +1 -1
- package/src/apps/AppLoader.js +50 -37
- package/src/apps/AppRuntime.js +32 -8
- package/src/client/InputHandler.js +233 -0
- package/src/client/JitterBuffer.js +207 -0
- package/src/client/KalmanFilter.js +125 -0
- package/src/client/MessageHandler.js +101 -0
- package/src/client/PhysicsNetworkClient.js +141 -68
- package/src/client/ReconnectManager.js +62 -0
- package/src/client/SmoothInterpolation.js +127 -0
- package/src/client/SnapshotProcessor.js +144 -0
- package/src/connection/ConnectionManager.js +21 -3
- package/src/connection/SessionStore.js +13 -3
- package/src/index.client.js +4 -6
- package/src/netcode/EventLog.js +29 -15
- package/src/netcode/LagCompensator.js +25 -26
- package/src/netcode/NetworkState.js +4 -1
- package/src/netcode/PhysicsIntegration.js +20 -6
- package/src/netcode/PlayerManager.js +10 -2
- package/src/netcode/SnapshotEncoder.js +66 -19
- package/src/netcode/TickSystem.js +13 -4
- package/src/physics/World.js +66 -13
- package/src/protocol/msgpack.js +90 -63
- package/src/sdk/ReloadHandlers.js +12 -2
- package/src/sdk/ReloadManager.js +5 -0
- package/src/sdk/ServerHandlers.js +50 -11
- package/src/sdk/StaticHandler.js +22 -6
- package/src/sdk/TickHandler.js +101 -34
- package/src/sdk/scaffold.js +28 -0
- package/src/sdk/server.js +59 -33
- package/src/shared/movement.js +2 -1
- package/src/spatial/Octree.js +5 -0
- package/apps/interactive-door/index.js +0 -33
- package/apps/patrol-npc/index.js +0 -37
- package/src/connection/QualityMonitor.js +0 -46
- package/src/debug/StateInspector.js +0 -42
- package/src/index.js +0 -1
- package/src/index.server.js +0 -27
- package/src/protocol/Codec.js +0 -60
- package/src/protocol/SequenceTracker.js +0 -71
- package/src/sdk/ClientMessageHandler.js +0 -80
- package/src/sdk/client.js +0 -122
- package/world/kaira.glb +0 -0
- package/world/schwust.glb +0 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.acorn || (g.acorn = {})).walk = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
|
|
5
|
+
|
|
6
|
+
// AST walker module for Mozilla Parser API compatible trees
|
|
7
|
+
|
|
8
|
+
// A simple walk is one where you simply specify callbacks to be
|
|
9
|
+
// called on specific nodes. The last two arguments are optional. A
|
|
10
|
+
// simple use would be
|
|
11
|
+
//
|
|
12
|
+
// walk.simple(myTree, {
|
|
13
|
+
// Expression: function(node) { ... }
|
|
14
|
+
// });
|
|
15
|
+
//
|
|
16
|
+
// to do something with all expressions. All Parser API node types
|
|
17
|
+
// can be used to identify node types, as well as Expression,
|
|
18
|
+
// Statement, and ScopeBody, which denote categories of nodes.
|
|
19
|
+
//
|
|
20
|
+
// The base argument can be used to pass a custom (recursive)
|
|
21
|
+
// walker, and state can be used to give this walked an initial
|
|
22
|
+
// state.
|
|
23
|
+
|
|
24
|
+
exports.simple = simple;
|
|
25
|
+
|
|
26
|
+
// An ancestor walk builds up an array of ancestor nodes (including
|
|
27
|
+
// the current node) and passes them to the callback as the state parameter.
|
|
28
|
+
exports.ancestor = ancestor;
|
|
29
|
+
|
|
30
|
+
// A recursive walk is one where your functions override the default
|
|
31
|
+
// walkers. They can modify and replace the state parameter that's
|
|
32
|
+
// threaded through the walk, and can opt how and whether to walk
|
|
33
|
+
// their child nodes (by calling their third argument on these
|
|
34
|
+
// nodes).
|
|
35
|
+
exports.recursive = recursive;
|
|
36
|
+
|
|
37
|
+
// Find a node with a given start, end, and type (all are optional,
|
|
38
|
+
// null can be used as wildcard). Returns a {node, state} object, or
|
|
39
|
+
// undefined when it doesn't find a matching node.
|
|
40
|
+
exports.findNodeAt = findNodeAt;
|
|
41
|
+
|
|
42
|
+
// Find the innermost node of a given type that contains the given
|
|
43
|
+
// position. Interface similar to findNodeAt.
|
|
44
|
+
exports.findNodeAround = findNodeAround;
|
|
45
|
+
|
|
46
|
+
// Find the outermost matching node after a given position.
|
|
47
|
+
exports.findNodeAfter = findNodeAfter;
|
|
48
|
+
|
|
49
|
+
// Find the outermost matching node before a given position.
|
|
50
|
+
exports.findNodeBefore = findNodeBefore;
|
|
51
|
+
|
|
52
|
+
// Used to create a custom walker. Will fill in all missing node
|
|
53
|
+
// type properties with the defaults.
|
|
54
|
+
exports.make = make;
|
|
55
|
+
Object.defineProperty(exports, "__esModule", {
|
|
56
|
+
value: true
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function simple(node, visitors, base, state) {
|
|
60
|
+
if (!base) base = exports.base;(function c(node, st, override) {
|
|
61
|
+
var type = override || node.type,
|
|
62
|
+
found = visitors[type];
|
|
63
|
+
base[type](node, st, c);
|
|
64
|
+
if (found) found(node, st);
|
|
65
|
+
})(node, state);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function ancestor(node, visitors, base, state) {
|
|
69
|
+
if (!base) base = exports.base;
|
|
70
|
+
if (!state) state = [];(function c(node, st, override) {
|
|
71
|
+
var type = override || node.type,
|
|
72
|
+
found = visitors[type];
|
|
73
|
+
if (node != st[st.length - 1]) {
|
|
74
|
+
st = st.slice();
|
|
75
|
+
st.push(node);
|
|
76
|
+
}
|
|
77
|
+
base[type](node, st, c);
|
|
78
|
+
if (found) found(node, st);
|
|
79
|
+
})(node, state);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function recursive(node, state, funcs, base) {
|
|
83
|
+
var visitor = funcs ? exports.make(funcs, base) : base;(function c(node, st, override) {
|
|
84
|
+
visitor[override || node.type](node, st, c);
|
|
85
|
+
})(node, state);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function makeTest(test) {
|
|
89
|
+
if (typeof test == "string") {
|
|
90
|
+
return function (type) {
|
|
91
|
+
return type == test;
|
|
92
|
+
};
|
|
93
|
+
} else if (!test) {
|
|
94
|
+
return function () {
|
|
95
|
+
return true;
|
|
96
|
+
};
|
|
97
|
+
} else {
|
|
98
|
+
return test;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var Found = function Found(node, state) {
|
|
103
|
+
_classCallCheck(this, Found);
|
|
104
|
+
|
|
105
|
+
this.node = node;this.state = state;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
function findNodeAt(node, start, end, test, base, state) {
|
|
109
|
+
test = makeTest(test);
|
|
110
|
+
if (!base) base = exports.base;
|
|
111
|
+
try {
|
|
112
|
+
;(function c(node, st, override) {
|
|
113
|
+
var type = override || node.type;
|
|
114
|
+
if ((start == null || node.start <= start) && (end == null || node.end >= end)) base[type](node, st, c);
|
|
115
|
+
if (test(type, node) && (start == null || node.start == start) && (end == null || node.end == end)) throw new Found(node, st);
|
|
116
|
+
})(node, state);
|
|
117
|
+
} catch (e) {
|
|
118
|
+
if (e instanceof Found) {
|
|
119
|
+
return e;
|
|
120
|
+
}throw e;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function findNodeAround(node, pos, test, base, state) {
|
|
125
|
+
test = makeTest(test);
|
|
126
|
+
if (!base) base = exports.base;
|
|
127
|
+
try {
|
|
128
|
+
;(function c(node, st, override) {
|
|
129
|
+
var type = override || node.type;
|
|
130
|
+
if (node.start > pos || node.end < pos) {
|
|
131
|
+
return;
|
|
132
|
+
}base[type](node, st, c);
|
|
133
|
+
if (test(type, node)) throw new Found(node, st);
|
|
134
|
+
})(node, state);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
if (e instanceof Found) {
|
|
137
|
+
return e;
|
|
138
|
+
}throw e;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function findNodeAfter(node, pos, test, base, state) {
|
|
143
|
+
test = makeTest(test);
|
|
144
|
+
if (!base) base = exports.base;
|
|
145
|
+
try {
|
|
146
|
+
;(function c(node, st, override) {
|
|
147
|
+
if (node.end < pos) {
|
|
148
|
+
return;
|
|
149
|
+
}var type = override || node.type;
|
|
150
|
+
if (node.start >= pos && test(type, node)) throw new Found(node, st);
|
|
151
|
+
base[type](node, st, c);
|
|
152
|
+
})(node, state);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
if (e instanceof Found) {
|
|
155
|
+
return e;
|
|
156
|
+
}throw e;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function findNodeBefore(node, pos, test, base, state) {
|
|
161
|
+
test = makeTest(test);
|
|
162
|
+
if (!base) base = exports.base;
|
|
163
|
+
var max = undefined;(function c(node, st, override) {
|
|
164
|
+
if (node.start > pos) {
|
|
165
|
+
return;
|
|
166
|
+
}var type = override || node.type;
|
|
167
|
+
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node)) max = new Found(node, st);
|
|
168
|
+
base[type](node, st, c);
|
|
169
|
+
})(node, state);
|
|
170
|
+
return max;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function make(funcs, base) {
|
|
174
|
+
if (!base) base = exports.base;
|
|
175
|
+
var visitor = {};
|
|
176
|
+
for (var type in base) visitor[type] = base[type];
|
|
177
|
+
for (var type in funcs) visitor[type] = funcs[type];
|
|
178
|
+
return visitor;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function skipThrough(node, st, c) {
|
|
182
|
+
c(node, st);
|
|
183
|
+
}
|
|
184
|
+
function ignore(_node, _st, _c) {}
|
|
185
|
+
|
|
186
|
+
// Node walkers.
|
|
187
|
+
|
|
188
|
+
var base = {};
|
|
189
|
+
|
|
190
|
+
exports.base = base;
|
|
191
|
+
base.Program = base.BlockStatement = function (node, st, c) {
|
|
192
|
+
for (var i = 0; i < node.body.length; ++i) {
|
|
193
|
+
c(node.body[i], st, "Statement");
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
base.Statement = skipThrough;
|
|
197
|
+
base.EmptyStatement = ignore;
|
|
198
|
+
base.ExpressionStatement = base.ParenthesizedExpression = function (node, st, c) {
|
|
199
|
+
return c(node.expression, st, "Expression");
|
|
200
|
+
};
|
|
201
|
+
base.IfStatement = function (node, st, c) {
|
|
202
|
+
c(node.test, st, "Expression");
|
|
203
|
+
c(node.consequent, st, "Statement");
|
|
204
|
+
if (node.alternate) c(node.alternate, st, "Statement");
|
|
205
|
+
};
|
|
206
|
+
base.LabeledStatement = function (node, st, c) {
|
|
207
|
+
return c(node.body, st, "Statement");
|
|
208
|
+
};
|
|
209
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
210
|
+
base.WithStatement = function (node, st, c) {
|
|
211
|
+
c(node.object, st, "Expression");
|
|
212
|
+
c(node.body, st, "Statement");
|
|
213
|
+
};
|
|
214
|
+
base.SwitchStatement = function (node, st, c) {
|
|
215
|
+
c(node.discriminant, st, "Expression");
|
|
216
|
+
for (var i = 0; i < node.cases.length; ++i) {
|
|
217
|
+
var cs = node.cases[i];
|
|
218
|
+
if (cs.test) c(cs.test, st, "Expression");
|
|
219
|
+
for (var j = 0; j < cs.consequent.length; ++j) {
|
|
220
|
+
c(cs.consequent[j], st, "Statement");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
base.ReturnStatement = base.YieldExpression = function (node, st, c) {
|
|
225
|
+
if (node.argument) c(node.argument, st, "Expression");
|
|
226
|
+
};
|
|
227
|
+
base.ThrowStatement = base.SpreadElement = base.RestElement = function (node, st, c) {
|
|
228
|
+
return c(node.argument, st, "Expression");
|
|
229
|
+
};
|
|
230
|
+
base.TryStatement = function (node, st, c) {
|
|
231
|
+
c(node.block, st, "Statement");
|
|
232
|
+
if (node.handler) c(node.handler.body, st, "ScopeBody");
|
|
233
|
+
if (node.finalizer) c(node.finalizer, st, "Statement");
|
|
234
|
+
};
|
|
235
|
+
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
236
|
+
c(node.test, st, "Expression");
|
|
237
|
+
c(node.body, st, "Statement");
|
|
238
|
+
};
|
|
239
|
+
base.ForStatement = function (node, st, c) {
|
|
240
|
+
if (node.init) c(node.init, st, "ForInit");
|
|
241
|
+
if (node.test) c(node.test, st, "Expression");
|
|
242
|
+
if (node.update) c(node.update, st, "Expression");
|
|
243
|
+
c(node.body, st, "Statement");
|
|
244
|
+
};
|
|
245
|
+
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
246
|
+
c(node.left, st, "ForInit");
|
|
247
|
+
c(node.right, st, "Expression");
|
|
248
|
+
c(node.body, st, "Statement");
|
|
249
|
+
};
|
|
250
|
+
base.ForInit = function (node, st, c) {
|
|
251
|
+
if (node.type == "VariableDeclaration") c(node, st);else c(node, st, "Expression");
|
|
252
|
+
};
|
|
253
|
+
base.DebuggerStatement = ignore;
|
|
254
|
+
|
|
255
|
+
base.FunctionDeclaration = function (node, st, c) {
|
|
256
|
+
return c(node, st, "Function");
|
|
257
|
+
};
|
|
258
|
+
base.VariableDeclaration = function (node, st, c) {
|
|
259
|
+
for (var i = 0; i < node.declarations.length; ++i) {
|
|
260
|
+
var decl = node.declarations[i];
|
|
261
|
+
if (decl.init) c(decl.init, st, "Expression");
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
base.Function = function (node, st, c) {
|
|
266
|
+
return c(node.body, st, "ScopeBody");
|
|
267
|
+
};
|
|
268
|
+
base.ScopeBody = function (node, st, c) {
|
|
269
|
+
return c(node, st, "Statement");
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
base.Expression = skipThrough;
|
|
273
|
+
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
274
|
+
base.ArrayExpression = base.ArrayPattern = function (node, st, c) {
|
|
275
|
+
for (var i = 0; i < node.elements.length; ++i) {
|
|
276
|
+
var elt = node.elements[i];
|
|
277
|
+
if (elt) c(elt, st, "Expression");
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
base.ObjectExpression = base.ObjectPattern = function (node, st, c) {
|
|
281
|
+
for (var i = 0; i < node.properties.length; ++i) {
|
|
282
|
+
c(node.properties[i], st);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
286
|
+
base.SequenceExpression = base.TemplateLiteral = function (node, st, c) {
|
|
287
|
+
for (var i = 0; i < node.expressions.length; ++i) {
|
|
288
|
+
c(node.expressions[i], st, "Expression");
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
292
|
+
c(node.argument, st, "Expression");
|
|
293
|
+
};
|
|
294
|
+
base.BinaryExpression = base.AssignmentExpression = base.AssignmentPattern = base.LogicalExpression = function (node, st, c) {
|
|
295
|
+
c(node.left, st, "Expression");
|
|
296
|
+
c(node.right, st, "Expression");
|
|
297
|
+
};
|
|
298
|
+
base.ConditionalExpression = function (node, st, c) {
|
|
299
|
+
c(node.test, st, "Expression");
|
|
300
|
+
c(node.consequent, st, "Expression");
|
|
301
|
+
c(node.alternate, st, "Expression");
|
|
302
|
+
};
|
|
303
|
+
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
304
|
+
c(node.callee, st, "Expression");
|
|
305
|
+
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i) {
|
|
306
|
+
c(node.arguments[i], st, "Expression");
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
base.MemberExpression = function (node, st, c) {
|
|
310
|
+
c(node.object, st, "Expression");
|
|
311
|
+
if (node.computed) c(node.property, st, "Expression");
|
|
312
|
+
};
|
|
313
|
+
base.ExportDeclaration = function (node, st, c) {
|
|
314
|
+
return c(node.declaration, st);
|
|
315
|
+
};
|
|
316
|
+
base.ImportDeclaration = function (node, st, c) {
|
|
317
|
+
for (var i = 0; i < node.specifiers.length; i++) {
|
|
318
|
+
c(node.specifiers[i], st);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
base.ImportSpecifier = base.ImportBatchSpecifier = base.Identifier = base.Literal = ignore;
|
|
322
|
+
|
|
323
|
+
base.TaggedTemplateExpression = function (node, st, c) {
|
|
324
|
+
c(node.tag, st, "Expression");
|
|
325
|
+
c(node.quasi, st);
|
|
326
|
+
};
|
|
327
|
+
base.ClassDeclaration = base.ClassExpression = function (node, st, c) {
|
|
328
|
+
if (node.superClass) c(node.superClass, st, "Expression");
|
|
329
|
+
for (var i = 0; i < node.body.body.length; i++) {
|
|
330
|
+
c(node.body.body[i], st);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
base.MethodDefinition = base.Property = function (node, st, c) {
|
|
334
|
+
if (node.computed) c(node.key, st, "Expression");
|
|
335
|
+
c(node.value, st, "Expression");
|
|
336
|
+
};
|
|
337
|
+
base.ComprehensionExpression = function (node, st, c) {
|
|
338
|
+
for (var i = 0; i < node.blocks.length; i++) {
|
|
339
|
+
c(node.blocks[i].right, st, "Expression");
|
|
340
|
+
}c(node.body, st, "Expression");
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
},{}]},{},[1])(1)
|
|
344
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<title><!-- title --></title>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="generator" content="Three.js Editor">
|
|
7
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: sans-serif;
|
|
11
|
+
font-size: 11px;
|
|
12
|
+
background-color: #000;
|
|
13
|
+
margin: 0px;
|
|
14
|
+
}
|
|
15
|
+
canvas {
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body ontouchstart="">
|
|
21
|
+
<script type="importmap">
|
|
22
|
+
{
|
|
23
|
+
"imports": {
|
|
24
|
+
"three": "./js/three.module.js"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
<script type="module">
|
|
29
|
+
|
|
30
|
+
import * as THREE from 'three';
|
|
31
|
+
import { APP } from './js/app.js';
|
|
32
|
+
|
|
33
|
+
window.THREE = THREE; // Used by APP Scripts.
|
|
34
|
+
|
|
35
|
+
var loader = new THREE.FileLoader();
|
|
36
|
+
loader.load( 'app.json', function ( text ) {
|
|
37
|
+
|
|
38
|
+
var player = new APP.Player();
|
|
39
|
+
player.load( JSON.parse( text ) );
|
|
40
|
+
player.setSize( window.innerWidth, window.innerHeight );
|
|
41
|
+
player.play();
|
|
42
|
+
|
|
43
|
+
document.body.appendChild( player.dom );
|
|
44
|
+
|
|
45
|
+
window.addEventListener( 'resize', function () {
|
|
46
|
+
|
|
47
|
+
player.setSize( window.innerWidth, window.innerHeight );
|
|
48
|
+
|
|
49
|
+
} );
|
|
50
|
+
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
/* edit button */
|
|
54
|
+
|
|
55
|
+
</script>
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
var APP = {
|
|
2
|
+
|
|
3
|
+
Player: function () {
|
|
4
|
+
|
|
5
|
+
var renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
6
|
+
renderer.setPixelRatio( window.devicePixelRatio ); // TODO: Use player.setPixelRatio()
|
|
7
|
+
|
|
8
|
+
var loader = new THREE.ObjectLoader();
|
|
9
|
+
var camera, scene;
|
|
10
|
+
|
|
11
|
+
var events = {};
|
|
12
|
+
|
|
13
|
+
var dom = document.createElement( 'div' );
|
|
14
|
+
dom.appendChild( renderer.domElement );
|
|
15
|
+
|
|
16
|
+
this.dom = dom;
|
|
17
|
+
this.canvas = renderer.domElement;
|
|
18
|
+
|
|
19
|
+
this.width = 500;
|
|
20
|
+
this.height = 500;
|
|
21
|
+
|
|
22
|
+
this.load = function ( json ) {
|
|
23
|
+
|
|
24
|
+
var project = json.project;
|
|
25
|
+
|
|
26
|
+
if ( project.shadows !== undefined ) renderer.shadowMap.enabled = project.shadows;
|
|
27
|
+
if ( project.shadowType !== undefined ) renderer.shadowMap.type = project.shadowType;
|
|
28
|
+
if ( project.toneMapping !== undefined ) renderer.toneMapping = project.toneMapping;
|
|
29
|
+
if ( project.toneMappingExposure !== undefined ) renderer.toneMappingExposure = project.toneMappingExposure;
|
|
30
|
+
|
|
31
|
+
this.setScene( loader.parse( json.scene ) );
|
|
32
|
+
this.setCamera( loader.parse( json.camera ) );
|
|
33
|
+
|
|
34
|
+
events = {
|
|
35
|
+
init: [],
|
|
36
|
+
start: [],
|
|
37
|
+
stop: [],
|
|
38
|
+
keydown: [],
|
|
39
|
+
keyup: [],
|
|
40
|
+
pointerdown: [],
|
|
41
|
+
pointerup: [],
|
|
42
|
+
pointermove: [],
|
|
43
|
+
update: []
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var scriptWrapParams = 'player,renderer,scene,camera';
|
|
47
|
+
var scriptWrapResultObj = {};
|
|
48
|
+
|
|
49
|
+
for ( var eventKey in events ) {
|
|
50
|
+
|
|
51
|
+
scriptWrapParams += ',' + eventKey;
|
|
52
|
+
scriptWrapResultObj[ eventKey ] = eventKey;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var scriptWrapResult = JSON.stringify( scriptWrapResultObj ).replace( /\"/g, '' );
|
|
57
|
+
|
|
58
|
+
for ( var uuid in json.scripts ) {
|
|
59
|
+
|
|
60
|
+
var object = scene.getObjectByProperty( 'uuid', uuid, true );
|
|
61
|
+
|
|
62
|
+
if ( object === undefined ) {
|
|
63
|
+
|
|
64
|
+
console.warn( 'APP.Player: Script without object.', uuid );
|
|
65
|
+
continue;
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var scripts = json.scripts[ uuid ];
|
|
70
|
+
|
|
71
|
+
for ( var i = 0; i < scripts.length; i ++ ) {
|
|
72
|
+
|
|
73
|
+
var script = scripts[ i ];
|
|
74
|
+
|
|
75
|
+
var functions = ( new Function( scriptWrapParams, script.source + '\nreturn ' + scriptWrapResult + ';' ).bind( object ) )( this, renderer, scene, camera );
|
|
76
|
+
|
|
77
|
+
for ( var name in functions ) {
|
|
78
|
+
|
|
79
|
+
if ( functions[ name ] === undefined ) continue;
|
|
80
|
+
|
|
81
|
+
if ( events[ name ] === undefined ) {
|
|
82
|
+
|
|
83
|
+
console.warn( 'APP.Player: Event type not supported (', name, ')' );
|
|
84
|
+
continue;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
events[ name ].push( functions[ name ].bind( object ) );
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
dispatch( events.init, arguments );
|
|
97
|
+
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
this.setCamera = function ( value ) {
|
|
101
|
+
|
|
102
|
+
camera = value;
|
|
103
|
+
camera.aspect = this.width / this.height;
|
|
104
|
+
camera.updateProjectionMatrix();
|
|
105
|
+
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
this.setScene = function ( value ) {
|
|
109
|
+
|
|
110
|
+
scene = value;
|
|
111
|
+
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
this.setPixelRatio = function ( pixelRatio ) {
|
|
115
|
+
|
|
116
|
+
renderer.setPixelRatio( pixelRatio );
|
|
117
|
+
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
this.setSize = function ( width, height ) {
|
|
121
|
+
|
|
122
|
+
this.width = width;
|
|
123
|
+
this.height = height;
|
|
124
|
+
|
|
125
|
+
if ( camera ) {
|
|
126
|
+
|
|
127
|
+
camera.aspect = this.width / this.height;
|
|
128
|
+
camera.updateProjectionMatrix();
|
|
129
|
+
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
renderer.setSize( width, height );
|
|
133
|
+
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
function dispatch( array, event ) {
|
|
137
|
+
|
|
138
|
+
for ( var i = 0, l = array.length; i < l; i ++ ) {
|
|
139
|
+
|
|
140
|
+
array[ i ]( event );
|
|
141
|
+
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var time, startTime, prevTime;
|
|
147
|
+
|
|
148
|
+
function animate() {
|
|
149
|
+
|
|
150
|
+
time = performance.now();
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
|
|
154
|
+
dispatch( events.update, { time: time - startTime, delta: time - prevTime } );
|
|
155
|
+
|
|
156
|
+
} catch ( e ) {
|
|
157
|
+
|
|
158
|
+
console.error( ( e.message || e ), ( e.stack || '' ) );
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
renderer.render( scene, camera );
|
|
163
|
+
|
|
164
|
+
prevTime = time;
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
this.play = function () {
|
|
169
|
+
|
|
170
|
+
startTime = prevTime = performance.now();
|
|
171
|
+
|
|
172
|
+
document.addEventListener( 'keydown', onKeyDown );
|
|
173
|
+
document.addEventListener( 'keyup', onKeyUp );
|
|
174
|
+
document.addEventListener( 'pointerdown', onPointerDown );
|
|
175
|
+
document.addEventListener( 'pointerup', onPointerUp );
|
|
176
|
+
document.addEventListener( 'pointermove', onPointerMove );
|
|
177
|
+
|
|
178
|
+
dispatch( events.start, arguments );
|
|
179
|
+
|
|
180
|
+
renderer.setAnimationLoop( animate );
|
|
181
|
+
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
this.stop = function () {
|
|
185
|
+
|
|
186
|
+
document.removeEventListener( 'keydown', onKeyDown );
|
|
187
|
+
document.removeEventListener( 'keyup', onKeyUp );
|
|
188
|
+
document.removeEventListener( 'pointerdown', onPointerDown );
|
|
189
|
+
document.removeEventListener( 'pointerup', onPointerUp );
|
|
190
|
+
document.removeEventListener( 'pointermove', onPointerMove );
|
|
191
|
+
|
|
192
|
+
dispatch( events.stop, arguments );
|
|
193
|
+
|
|
194
|
+
renderer.setAnimationLoop( null );
|
|
195
|
+
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
this.render = function ( time ) {
|
|
199
|
+
|
|
200
|
+
dispatch( events.update, { time: time * 1000, delta: 0 /* TODO */ } );
|
|
201
|
+
|
|
202
|
+
renderer.render( scene, camera );
|
|
203
|
+
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
this.dispose = function () {
|
|
207
|
+
|
|
208
|
+
renderer.dispose();
|
|
209
|
+
|
|
210
|
+
camera = undefined;
|
|
211
|
+
scene = undefined;
|
|
212
|
+
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
//
|
|
216
|
+
|
|
217
|
+
function onKeyDown( event ) {
|
|
218
|
+
|
|
219
|
+
dispatch( events.keydown, event );
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function onKeyUp( event ) {
|
|
224
|
+
|
|
225
|
+
dispatch( events.keyup, event );
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function onPointerDown( event ) {
|
|
230
|
+
|
|
231
|
+
dispatch( events.pointerdown, event );
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function onPointerUp( event ) {
|
|
236
|
+
|
|
237
|
+
dispatch( events.pointerup, event );
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function onPointerMove( event ) {
|
|
242
|
+
|
|
243
|
+
dispatch( events.pointermove, event );
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export { APP };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.CodeMirror-dialog {
|
|
2
|
+
position: absolute;
|
|
3
|
+
left: 0; right: 0;
|
|
4
|
+
background: inherit;
|
|
5
|
+
z-index: 15;
|
|
6
|
+
padding: .1em .8em;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
color: inherit;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.CodeMirror-dialog-top {
|
|
12
|
+
border-bottom: 1px solid #eee;
|
|
13
|
+
top: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.CodeMirror-dialog-bottom {
|
|
17
|
+
border-top: 1px solid #eee;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.CodeMirror-dialog input {
|
|
22
|
+
border: none;
|
|
23
|
+
outline: none;
|
|
24
|
+
background: transparent;
|
|
25
|
+
width: 20em;
|
|
26
|
+
color: inherit;
|
|
27
|
+
font-family: monospace;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.CodeMirror-dialog button {
|
|
31
|
+
font-size: 70%;
|
|
32
|
+
}
|