@xort/cga 0.0.83 → 0.0.85

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.
Files changed (65) hide show
  1. package/build/@xort_cga.js +871 -1010
  2. package/deploy.sh +13 -1
  3. package/dist/IKanimation/Bone.d.ts +1 -3
  4. package/dist/IKanimation/Bone.js +4 -22
  5. package/dist/alg/extrude.js +4 -4
  6. package/dist/extends/geometryaid.js +7 -15
  7. package/dist/index.d.ts +1 -2
  8. package/dist/index.js +1 -2
  9. package/dist/math/Color.d.ts +2 -2
  10. package/dist/math/Color.js +24 -31
  11. package/dist/math/Euler.d.ts +4 -5
  12. package/dist/math/Euler.js +16 -34
  13. package/dist/math/HVec3.d.ts +1 -2
  14. package/dist/math/HVec3.js +13 -30
  15. package/dist/math/Quat.d.ts +1 -2
  16. package/dist/math/Quat.js +23 -43
  17. package/dist/math/Vec2.d.ts +4 -4
  18. package/dist/math/Vec2.js +7 -24
  19. package/dist/math/Vec3.d.ts +5 -9
  20. package/dist/math/Vec3.js +35 -52
  21. package/dist/math/Vec4.d.ts +4 -4
  22. package/dist/math/Vec4.js +11 -28
  23. package/dist/math/vecs.d.ts +19 -6
  24. package/dist/math/vecs.js +31 -1
  25. package/dist/render/{buffer-attribute.d.ts → bufferAttribute.d.ts} +8 -4
  26. package/dist/render/{buffer-attribute.js → bufferAttribute.js} +4 -0
  27. package/dist/render/geometry.d.ts +7 -9
  28. package/dist/render/geometry.js +22 -25
  29. package/dist/render/mesh.d.ts +23 -18
  30. package/dist/render/mesh.js +62 -57
  31. package/dist/render/types.d.ts +1 -0
  32. package/dist/struct/3d/Box.d.ts +1 -1
  33. package/dist/struct/3d/Plane.js +1 -1
  34. package/package.json +73 -73
  35. package/rollup.config.js +1 -1
  36. package/src/IKanimation/Bone.ts +1 -5
  37. package/src/alg/extrude.ts +6 -6
  38. package/src/app.ts +2 -10
  39. package/src/extends/geometryaid.ts +10 -13
  40. package/src/index.ts +2 -4
  41. package/src/math/Color.ts +18 -7
  42. package/src/math/Euler.ts +11 -12
  43. package/src/math/HVec3.ts +3 -5
  44. package/src/math/Quat.ts +18 -23
  45. package/src/math/Vec2.ts +7 -7
  46. package/src/math/Vec3.ts +37 -36
  47. package/src/math/Vec4.ts +9 -9
  48. package/src/math/vecs.ts +50 -8
  49. package/src/render/{buffer-attribute.ts → bufferAttribute.ts} +11 -4
  50. package/src/render/geometry.ts +18 -15
  51. package/src/render/mesh.ts +56 -54
  52. package/src/render/types.ts +2 -0
  53. package/src/struct/3d/Box.ts +1 -1
  54. package/src/struct/3d/Plane.ts +2 -4
  55. package/dist/math/Vec.d.ts +0 -7
  56. package/dist/math/Vec.js +0 -41
  57. package/dist/math/vector.d.ts +0 -114
  58. package/dist/math/vector.js +0 -371
  59. package/dist/render/eventhandler.d.ts +0 -78
  60. package/dist/render/eventhandler.js +0 -191
  61. package/dist/render/thing.d.ts +0 -34
  62. package/dist/render/thing.js +0 -194
  63. package/src/math/Vec.ts +0 -26
  64. package/src/render/eventhandler.ts +0 -196
  65. package/src/render/thing.ts +0 -204
@@ -1,78 +0,0 @@
1
- export declare class EventHandler {
2
- private _callbacks;
3
- private _callbackActive;
4
- constructor();
5
- _addCallback(name: string, callback: any, scope: any, once: boolean): void;
6
- /**
7
- * @function
8
- * @name EventHandler#on
9
- * @description Attach an event handler to an event.
10
- * @param {string} name - Name of the event to bind the callback to.
11
- * @param {callbacks.HandleEvent} callback - Function that is called when event is fired. Note the callback is limited to 8 arguments.
12
- * @param {object} [scope] - Object to use as 'this' when the event is fired, defaults to current this.
13
- * @returns {EventHandler} Self for chaining.
14
- * @example
15
- * obj.on('test', function (a, b) {
16
- * console.log(a + b);
17
- * });
18
- * obj.fire('test', 1, 2); // prints 3 to the console
19
- */
20
- on(name: string | string[], callback: any, scope?: any): this;
21
- /**
22
- * @function
23
- * @name EventHandler#off
24
- * @description Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event,
25
- * if scope is not provided then all events with the callback will be unbound.
26
- * @param {string} [name] - Name of the event to unbind.
27
- * @param {callbacks.HandleEvent} [callback] - Function to be unbound.
28
- * @param {object} [scope] - Scope that was used as the this when the event is fired.
29
- * @returns {EventHandler} Self for chaining.
30
- * @example
31
- * var handler = function () {
32
- * };
33
- * obj.on('test', handler);
34
- *
35
- * obj.off(); // Removes all events
36
- * obj.off('test'); // Removes all events called 'test'
37
- * obj.off('test', handler); // Removes all handler functions, called 'test'
38
- * obj.off('test', handler, this); // Removes all hander functions, called 'test' with scope this
39
- */
40
- off(name: string | number, callback: any, scope: any): this;
41
- /**
42
- * @function
43
- * @name EventHandler#fire
44
- * @description Fire an event, all additional arguments are passed on to the event listener.
45
- * @param {object} name - Name of event to fire.
46
- * @param {*} [args] - arguments that is passed to the event handler.
47
- * obj.fire('test', 'This is the message');
48
- */
49
- fire(name: string | number, ...args: any[]): this;
50
- /**
51
- * @function
52
- * @name EventHandler#once
53
- * @description Attach an event handler to an event. This handler will be removed after being fired once.
54
- * @param {string} name - Name of the event to bind the callback to.
55
- * @param {callbacks.HandleEvent} callback - Function that is called when event is fired. Note the callback is limited to 8 arguments.
56
- * @param {object} [scope] - Object to use as 'this' when the event is fired, defaults to current this.
57
- * @returns {EventHandler} Self for chaining.
58
- * @example
59
- * obj.once('test', function (a, b) {
60
- * console.log(a + b);
61
- * });
62
- * obj.fire('test', 1, 2); // prints 3 to the console
63
- * obj.fire('test', 1, 2); // not going to get handled
64
- */
65
- once(name: string, callback: any, scope: any): this;
66
- /**
67
- * @function
68
- * @name EventHandler#hasEvent
69
- * @description Test if there are any handlers bound to an event name.
70
- * @param {string} name - The name of the event to test.
71
- * @returns {boolean} True if the object has handlers bound to the specified event name.
72
- * @example
73
- * obj.on('test', function () { }); // bind an event to 'test'
74
- * obj.hasEvent('test'); // returns true
75
- * obj.hasEvent('hello'); // returns false
76
- */
77
- hasEvent(name: string | number): boolean;
78
- }
@@ -1,191 +0,0 @@
1
- "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.EventHandler = void 0;
11
- var EventHandler = /** @class */ (function () {
12
- function EventHandler() {
13
- this._callbacks = {};
14
- this._callbackActive = {};
15
- }
16
- EventHandler.prototype._addCallback = function (name, callback, scope, once) {
17
- if (!name || typeof name !== 'string' || !callback)
18
- return;
19
- if (!this._callbacks[name])
20
- this._callbacks[name] = [];
21
- if (this._callbackActive[name] && this._callbackActive[name] === this._callbacks[name])
22
- this._callbackActive[name] = this._callbackActive[name].slice();
23
- this._callbacks[name].push({
24
- callback: callback,
25
- scope: scope || this,
26
- once: once || false
27
- });
28
- };
29
- /**
30
- * @function
31
- * @name EventHandler#on
32
- * @description Attach an event handler to an event.
33
- * @param {string} name - Name of the event to bind the callback to.
34
- * @param {callbacks.HandleEvent} callback - Function that is called when event is fired. Note the callback is limited to 8 arguments.
35
- * @param {object} [scope] - Object to use as 'this' when the event is fired, defaults to current this.
36
- * @returns {EventHandler} Self for chaining.
37
- * @example
38
- * obj.on('test', function (a, b) {
39
- * console.log(a + b);
40
- * });
41
- * obj.fire('test', 1, 2); // prints 3 to the console
42
- */
43
- EventHandler.prototype.on = function (name, callback, scope) {
44
- var _this = this;
45
- if (Array.isArray(name))
46
- name.forEach(function (v) { return _this._addCallback(v, callback, scope, false); });
47
- else
48
- this._addCallback(name, callback, scope, false);
49
- return this;
50
- };
51
- /**
52
- * @function
53
- * @name EventHandler#off
54
- * @description Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event,
55
- * if scope is not provided then all events with the callback will be unbound.
56
- * @param {string} [name] - Name of the event to unbind.
57
- * @param {callbacks.HandleEvent} [callback] - Function to be unbound.
58
- * @param {object} [scope] - Scope that was used as the this when the event is fired.
59
- * @returns {EventHandler} Self for chaining.
60
- * @example
61
- * var handler = function () {
62
- * };
63
- * obj.on('test', handler);
64
- *
65
- * obj.off(); // Removes all events
66
- * obj.off('test'); // Removes all events called 'test'
67
- * obj.off('test', handler); // Removes all handler functions, called 'test'
68
- * obj.off('test', handler, this); // Removes all hander functions, called 'test' with scope this
69
- */
70
- EventHandler.prototype.off = function (name, callback, scope) {
71
- if (name) {
72
- if (this._callbackActive[name] && this._callbackActive[name] === this._callbacks[name])
73
- this._callbackActive[name] = this._callbackActive[name].slice();
74
- }
75
- else {
76
- for (var key in this._callbackActive) {
77
- if (!this._callbacks[key])
78
- continue;
79
- if (this._callbacks[key] !== this._callbackActive[key])
80
- continue;
81
- this._callbackActive[key] = this._callbackActive[key].slice();
82
- }
83
- }
84
- if (!name) {
85
- this._callbacks = {};
86
- }
87
- else if (!callback) {
88
- if (this._callbacks[name])
89
- this._callbacks[name] = [];
90
- }
91
- else {
92
- var events = this._callbacks[name];
93
- if (!events)
94
- return this;
95
- var count = events.length;
96
- for (var i = 0; i < count; i++) {
97
- if (events[i].callback !== callback)
98
- continue;
99
- if (scope && events[i].scope !== scope)
100
- continue;
101
- events[i--] = events[--count];
102
- }
103
- events.length = count;
104
- }
105
- return this;
106
- };
107
- // ESLint rule disabled here as documenting arg1, arg2...argN as [...] rest
108
- // arguments is preferable to documenting each one individually.
109
- /* eslint-disable valid-jsdoc */
110
- /**
111
- * @function
112
- * @name EventHandler#fire
113
- * @description Fire an event, all additional arguments are passed on to the event listener.
114
- * @param {object} name - Name of event to fire.
115
- * @param {*} [args] - arguments that is passed to the event handler.
116
- * obj.fire('test', 'This is the message');
117
- */
118
- /* eslint-enable valid-jsdoc */
119
- EventHandler.prototype.fire = function (name) {
120
- var _a;
121
- var args = [];
122
- for (var _i = 1; _i < arguments.length; _i++) {
123
- args[_i - 1] = arguments[_i];
124
- }
125
- if (!name || !this._callbacks[name])
126
- return this;
127
- var callbacks;
128
- if (!this._callbackActive[name]) {
129
- this._callbackActive[name] = this._callbacks[name];
130
- }
131
- else {
132
- if (this._callbackActive[name] === this._callbacks[name])
133
- this._callbackActive[name] = this._callbackActive[name].slice();
134
- callbacks = this._callbacks[name].slice();
135
- }
136
- // TODO: What does callbacks do here?
137
- // In particular this condition check looks wrong: (i < (callbacks || this._callbackActive[name]).length)
138
- // Because callbacks is not an integer
139
- // eslint-disable-next-line no-unmodified-loop-condition
140
- for (var i = 0; (callbacks || this._callbackActive[name]) && (i < (callbacks || this._callbackActive[name]).length); i++) {
141
- var evt = (callbacks || this._callbackActive[name])[i];
142
- (_a = evt.callback).call.apply(_a, __spreadArrays([evt.scope], args));
143
- if (evt.once) {
144
- var ind = this._callbacks[name].indexOf(evt);
145
- if (ind !== -1) {
146
- if (this._callbackActive[name] === this._callbacks[name])
147
- this._callbackActive[name] = this._callbackActive[name].slice();
148
- this._callbacks[name].splice(ind, 1);
149
- }
150
- }
151
- }
152
- if (!callbacks)
153
- this._callbackActive[name] = null;
154
- return this;
155
- };
156
- /**
157
- * @function
158
- * @name EventHandler#once
159
- * @description Attach an event handler to an event. This handler will be removed after being fired once.
160
- * @param {string} name - Name of the event to bind the callback to.
161
- * @param {callbacks.HandleEvent} callback - Function that is called when event is fired. Note the callback is limited to 8 arguments.
162
- * @param {object} [scope] - Object to use as 'this' when the event is fired, defaults to current this.
163
- * @returns {EventHandler} Self for chaining.
164
- * @example
165
- * obj.once('test', function (a, b) {
166
- * console.log(a + b);
167
- * });
168
- * obj.fire('test', 1, 2); // prints 3 to the console
169
- * obj.fire('test', 1, 2); // not going to get handled
170
- */
171
- EventHandler.prototype.once = function (name, callback, scope) {
172
- this._addCallback(name, callback, scope, true);
173
- return this;
174
- };
175
- /**
176
- * @function
177
- * @name EventHandler#hasEvent
178
- * @description Test if there are any handlers bound to an event name.
179
- * @param {string} name - The name of the event to test.
180
- * @returns {boolean} True if the object has handlers bound to the specified event name.
181
- * @example
182
- * obj.on('test', function () { }); // bind an event to 'test'
183
- * obj.hasEvent('test'); // returns true
184
- * obj.hasEvent('hello'); // returns false
185
- */
186
- EventHandler.prototype.hasEvent = function (name) {
187
- return (this._callbacks[name] && this._callbacks[name].length !== 0) || false;
188
- };
189
- return EventHandler;
190
- }());
191
- exports.EventHandler = EventHandler;
@@ -1,34 +0,0 @@
1
- import { EventHandler } from './eventhandler';
2
- export declare class Thing extends EventHandler {
3
- protected cache: any;
4
- uuid: any;
5
- id: any;
6
- name: any;
7
- alias: any;
8
- isThing: boolean;
9
- parent: any;
10
- children: any[];
11
- meta: any;
12
- needsUpdate: boolean;
13
- _renderObject: any;
14
- _useData: any;
15
- tag: string;
16
- constructor(opts?: any);
17
- add(thing: any, force?: boolean): this;
18
- remove(thing: any): this;
19
- foreach(cb: (arg0: this) => void): void;
20
- getObjectByProperty(name: string, value: any): any;
21
- getObjectById(id: any): any;
22
- getObjectByName(name: any): any;
23
- /**
24
- * 生成属性的set/get方法
25
- * @param {string} name
26
- * @param {function} setFunc
27
- * @param {boolean} skipEqualsCheck
28
- */
29
- defineProperty(name: string | number | symbol, setFunc: any, skipEqualsCheck?: boolean): void;
30
- buildAccessor(name: any, bindObject?: any): void;
31
- buildAccessors(schema: any[], bindObject?: this): void;
32
- }
33
- export declare function buildAccessor(name: any, bindObject: any): void;
34
- export declare function buildAccessors(schema: any[], bindObject: any): void;
@@ -1,194 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.buildAccessors = exports.buildAccessor = exports.Thing = void 0;
17
- var eventhandler_1 = require("./eventhandler");
18
- var uuid_1 = require("uuid");
19
- var Thing = /** @class */ (function (_super) {
20
- __extends(Thing, _super);
21
- function Thing(opts) {
22
- var _this = _super.call(this) || this;
23
- _this.cache = {};
24
- _this._useData = {};
25
- opts = opts || {};
26
- _this.uuid = uuid_1.v4();
27
- _this.id = _this.uuid;
28
- _this.name = opts.name || "未命名";
29
- _this.alias = opts.alias;
30
- _this.isThing = true;
31
- _this.parent = null;
32
- _this.children = [];
33
- _this.meta = undefined;
34
- _this.needsUpdate = false;
35
- _this._renderObject = null;
36
- _this._useData = {};
37
- _this.tag = "untagged";
38
- _this.on("set", function (name, oldValue, newValue) {
39
- _this.fire("set_" + name, name, oldValue, newValue);
40
- });
41
- for (var key in opts) {
42
- if (opts.hasOwnProperty(key)) {
43
- if (!_this[key]) {
44
- _this[key] = opts[key];
45
- }
46
- }
47
- }
48
- return _this;
49
- }
50
- Thing.prototype.add = function (thing, force) {
51
- if (force === void 0) { force = false; }
52
- if (arguments.length > 1) {
53
- for (var i = 0; i < arguments.length; i++) {
54
- this.add(arguments[i]);
55
- }
56
- return this;
57
- }
58
- if (thing === this) {
59
- console.error("Thing.add: 自己不能作为自己的子节点", thing);
60
- return this;
61
- }
62
- if (thing && this.isThing) {
63
- if (thing.parent) {
64
- thing.parent.remove(thing);
65
- }
66
- thing.parent = this;
67
- this.children.push(thing);
68
- }
69
- else if (thing && force) {
70
- if (thing.parent) {
71
- thing.parent.remove(thing);
72
- }
73
- thing.parent = this;
74
- this.children.push(thing);
75
- }
76
- else {
77
- console.error("Thing.add:不是Thing类型", thing);
78
- }
79
- return this;
80
- };
81
- Thing.prototype.remove = function (thing) {
82
- if (arguments.length > 1) {
83
- for (var i = 0; i < arguments.length; i++) {
84
- this.remove(arguments[i]);
85
- }
86
- return this;
87
- }
88
- var index = this.children.indexOf(thing);
89
- if (index !== -1) {
90
- thing.parent = null;
91
- // thing.dispatchEvent( { type: 'removed' } );
92
- this.children.splice(index, 1);
93
- }
94
- return this;
95
- };
96
- Thing.prototype.foreach = function (cb) {
97
- cb(this);
98
- var children = this.children;
99
- for (var i = 0; i < children.length; i++) {
100
- children[i].foreach(cb);
101
- }
102
- };
103
- Thing.prototype.getObjectByProperty = function (name, value) {
104
- if (this[name] === value)
105
- return this;
106
- for (var i = 0, l = this.children.length; i < l; i++) {
107
- var child = this.children[i];
108
- if (!child.getObjectByProperty)
109
- continue;
110
- var object = child.getObjectByProperty(name, value);
111
- if (object !== undefined) {
112
- return object;
113
- }
114
- }
115
- return undefined;
116
- };
117
- Thing.prototype.getObjectById = function (id) {
118
- return this.getObjectByProperty('id', id);
119
- };
120
- Thing.prototype.getObjectByName = function (name) {
121
- return this.getObjectByProperty('name', name);
122
- };
123
- /**
124
- * 生成属性的set/get方法
125
- * @param {string} name
126
- * @param {function} setFunc
127
- * @param {boolean} skipEqualsCheck
128
- */
129
- Thing.prototype.defineProperty = function (name, setFunc, skipEqualsCheck) {
130
- var _this = this;
131
- if (skipEqualsCheck === void 0) { skipEqualsCheck = true; }
132
- Object.defineProperty(this, name, {
133
- get: function () {
134
- return _this._useData[name];
135
- },
136
- set: function (value) {
137
- var data = _this._useData;
138
- var oldValue = data[name];
139
- if (!skipEqualsCheck && oldValue === value)
140
- return;
141
- data[name] = value;
142
- if (setFunc)
143
- setFunc.call(_this, value, oldValue);
144
- },
145
- configurable: true
146
- });
147
- };
148
- Thing.prototype.buildAccessor = function (name, bindObject) {
149
- if (bindObject === void 0) { bindObject = this; }
150
- if (!bindObject)
151
- return;
152
- Object.defineProperty(bindObject, name, {
153
- get: function () {
154
- return bindObject["_" + name];
155
- },
156
- set: function (value) {
157
- var oldValue = bindObject["_" + name];
158
- bindObject["_" + name] = value;
159
- bindObject.fire('set', name, oldValue, value);
160
- },
161
- configurable: true
162
- });
163
- };
164
- Thing.prototype.buildAccessors = function (schema, bindObject) {
165
- var _this = this;
166
- schema.forEach(function (descriptor) {
167
- _this.buildAccessor(descriptor, bindObject);
168
- });
169
- };
170
- return Thing;
171
- }(eventhandler_1.EventHandler));
172
- exports.Thing = Thing;
173
- function buildAccessor(name, bindObject) {
174
- if (!bindObject)
175
- return;
176
- Object.defineProperty(bindObject, name, {
177
- get: function () {
178
- return bindObject["_" + name];
179
- },
180
- set: function (value) {
181
- var oldValue = bindObject["_" + name];
182
- bindObject["_" + name] = value;
183
- bindObject.fire('set', name, oldValue, value);
184
- },
185
- configurable: true
186
- });
187
- }
188
- exports.buildAccessor = buildAccessor;
189
- function buildAccessors(schema, bindObject) {
190
- schema.forEach(function (descriptor) {
191
- buildAccessor(descriptor, bindObject);
192
- });
193
- }
194
- exports.buildAccessors = buildAccessors;
package/src/math/Vec.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * 暂不使用
3
- */
4
- export class Vec extends Array {
5
- constructor(n: number) {
6
- super();
7
- while (n-- > 0) {
8
- this[this.length] = 0;
9
- }
10
- }
11
-
12
- static max(array: ArrayLike<number>) {
13
-
14
- if (array.length === 0) return - Infinity;
15
-
16
- var max = array[0];
17
-
18
- for (var i = 1, l = array.length; i < l; ++i) {
19
-
20
- if (array[i] > max) max = array[i];
21
-
22
- }
23
-
24
- return max;
25
- }
26
- }