├── dist
└── .keep
├── .gitattributes
├── core
├── test
│ ├── transformSystem
│ │ ├── TransformSystem.spec.js
│ │ ├── TransformSystem.api.js
│ │ └── TransformSystem.stub.js
│ ├── channel
│ │ ├── Channel.api.js
│ │ └── Channel.stub.js
│ ├── pathStore
│ │ ├── PathStore.api.js
│ │ ├── PathStore.stub.js
│ │ └── PathStore.helpers.js
│ ├── clock
│ │ ├── Clock.api.js
│ │ └── Clock.stub.js
│ ├── path
│ │ ├── Path.api.js
│ │ ├── Path.stub.js
│ │ └── Path.helpers.js
│ ├── dispatch
│ │ ├── Dispatch.stub.js
│ │ └── Dispatch.api.js
│ ├── node
│ │ ├── Node.stub.js
│ │ └── Node.api.js
│ ├── transform
│ │ ├── Transform.stub.js
│ │ └── Transform.api.js
│ ├── famousEngine
│ │ └── FamousEngine.api.js
│ ├── expected
│ │ └── DefaultNodeSpec.json
│ ├── helpers
│ │ ├── MockNode.js
│ │ └── SizeTestCaseGenerator.js
│ ├── Size.js
│ └── event
│ │ └── Event.spec.js
├── index.js
└── Event.js
├── .gitignore
├── transitions
├── perf
│ ├── index.html
│ └── index.js
├── index.js
└── test
│ └── Curves.js
├── .travis.yml
├── LICENSE
├── dom-renderables
└── index.js
├── webgl-materials
├── index.js
└── TextureRegistry.js
├── math
└── index.js
├── webgl-renderables
├── index.js
├── test
│ ├── MockColor.js
│ └── MockDispatch.js
└── lights
│ └── AmbientLight.js
├── polyfills
├── index.js
└── animationFrame.js
├── render-loops
├── index.js
├── now.js
└── test
│ └── now.js
├── renderers
├── index.js
├── test
│ ├── Context.js
│ └── TestingWindow.js
└── inject-css.js
├── webgl-shaders
├── index.js
├── chunks
│ ├── lowpRandom.glsl
│ ├── random.glsl
│ ├── applyMaterial.glsl
│ ├── transpose.glsl
│ ├── applyLight.glsl
│ └── getNormalMatrix.glsl
└── FragmentShader.glsl
├── AUTHORS.md
├── dom-renderers
├── index.js
├── events
│ ├── index.js
│ ├── FocusEvent.js
│ ├── UIEvent.js
│ ├── CompositionEvent.js
│ └── InputEvent.js
├── VoidElements.js
└── ElementCache.js
├── utilities
├── Registry.js
├── test
│ ├── clamp.js
│ ├── KeyCodes.js
│ ├── vendorPrefix.js
│ ├── clone.js
│ ├── keyValueToArrays.js
│ └── ObjectManager.js
├── index.js
├── clamp.js
├── loadURL.js
├── vendorPrefix.js
├── clone.js
├── keyValueToArrays.js
├── strip.js
└── KeyCodes.js
├── .eslintrc
├── components
├── index.js
├── Scale.js
├── Align.js
├── Origin.js
├── MountPoint.js
└── Rotation.js
├── webgl-renderers
├── index.js
├── createCheckerboard.js
├── test
│ ├── radixSort.spec.js
│ ├── createCheckerBoard.spec.js
│ └── Buffer.spec.js
└── Buffer.js
├── physics
├── test
│ ├── bodies
│ │ ├── Box.spec.js
│ │ └── Wall.spec.js
│ ├── forces
│ │ ├── Force.spec.js
│ │ ├── Drag.spec.js
│ │ ├── RotationalDrag.spec.js
│ │ └── Gravity3D.spec.js
│ └── constraints
│ │ └── Constraint.spec.js
├── index.js
├── bodies
│ ├── Box.js
│ └── Wall.js
└── constraints
│ └── Constraint.js
├── index.js
├── webgl-geometries
├── index.js
├── test
│ └── Geometry.spec.js
├── Geometry.js
└── primitives
│ ├── Triangle.js
│ ├── Icosahedron.js
│ ├── Box.js
│ └── Sphere.js
└── CONTRIBUTING.md
/dist/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/core/test/transformSystem/TransformSystem.spec.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .DS_Store
3 | dist/*.js
4 | *.log
5 |
--------------------------------------------------------------------------------
/core/test/channel/Channel.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'sendMessage',
3 | 'postMessage'
4 | ];
5 |
--------------------------------------------------------------------------------
/core/test/pathStore/PathStore.api.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = [
3 | 'insert',
4 | 'remove',
5 | 'get',
6 | 'getItems',
7 | 'getPaths'
8 | ];
9 |
10 |
--------------------------------------------------------------------------------
/core/test/transformSystem/TransformSystem.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'registerTransformAtPath',
3 | 'deregisterTransformAtPath',
4 | 'makeBreakPointAt',
5 | 'get',
6 | 'onUpdate'
7 | ];
8 |
9 |
--------------------------------------------------------------------------------
/core/test/clock/Clock.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'setScale',
3 | 'getScale',
4 | 'step',
5 | 'now',
6 | 'getTime',
7 | 'getFrame',
8 | 'setTimeout',
9 | 'setInterval',
10 | 'clearTimer'
11 | ];
12 |
--------------------------------------------------------------------------------
/core/test/path/Path.api.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = [
3 | 'hasTrailingSlash',
4 | 'depth',
5 | 'index',
6 | 'indexAtDepth',
7 | 'parent',
8 | 'isChildOf',
9 | 'isDescendentOf',
10 | 'getSelector'
11 | ];
12 |
--------------------------------------------------------------------------------
/core/test/path/Path.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Path.api');
4 | var sinon = require('sinon');
5 |
6 | var path = {};
7 |
8 | api.forEach(function (method) {
9 | path[method] = sinon.stub();
10 | });
11 |
12 | module.exports = path;
13 |
14 |
--------------------------------------------------------------------------------
/core/test/dispatch/Dispatch.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Dispatch.api');
4 | var sinon = require('sinon');
5 |
6 | var Dispatch = {};
7 |
8 | api.forEach(function (method) {
9 | Dispatch[method] = sinon.stub();
10 | });
11 |
12 | module.exports = Dispatch;
13 |
14 |
--------------------------------------------------------------------------------
/core/test/clock/Clock.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Clock.api');
4 | var sinon = require('sinon');
5 |
6 | function Clock () {
7 | api.forEach(function (method) {
8 | this[method] = sinon.stub();
9 | }.bind(this));
10 | }
11 |
12 | module.exports = Clock;
13 |
--------------------------------------------------------------------------------
/core/test/node/Node.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Node.api');
4 | var sinon = require('sinon');
5 |
6 | function Node () {
7 | api.forEach(function (method) {
8 | this[method] = sinon.stub();
9 | }.bind(this));
10 | }
11 |
12 | module.exports = Node;
13 |
14 |
--------------------------------------------------------------------------------
/core/test/channel/Channel.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Channel.api');
4 | var sinon = require('sinon');
5 |
6 | function Channel () {
7 | api.forEach(function (method) {
8 | this[method] = sinon.stub();
9 | }.bind(this));
10 | }
11 |
12 | module.exports = Channel;
13 |
--------------------------------------------------------------------------------
/core/test/dispatch/Dispatch.api.js:
--------------------------------------------------------------------------------
1 |
2 | module.exports = [
3 | '_setUpdater',
4 | 'addChildrenToQueue',
5 | 'next',
6 | 'breadthFirstNext',
7 | 'mount',
8 | 'dismount',
9 | 'getNode',
10 | 'show',
11 | 'hide',
12 | 'lookupNode',
13 | 'dispatch',
14 | 'dispatchUIEvent'
15 | ];
16 |
--------------------------------------------------------------------------------
/core/test/pathStore/PathStore.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var sinon = require('sinon');
4 | var api = require('./PathStore.api');
5 |
6 | function PathStore () {
7 | api.forEach(function (method) {
8 | this[method] = sinon.stub();
9 | }.bind(this));
10 | }
11 |
12 | module.exports = PathStore;
13 |
14 |
--------------------------------------------------------------------------------
/core/test/transform/Transform.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./Transform.api');
4 | var sinon = require('sinon');
5 |
6 | function Transform (parent) {
7 | api.forEach(function (method) {
8 | this[method] = sinon.stub();
9 | }.bind(this));
10 | }
11 |
12 | module.exports = Transform;
13 |
--------------------------------------------------------------------------------
/core/test/transformSystem/TransformSystem.stub.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var api = require('./TransformSystem.api');
4 | var sinon = require('sinon');
5 |
6 | var TransformSystem = {};
7 |
8 | api.forEach(function (method) {
9 | TransformSystem[method] = sinon.stub();
10 | });
11 |
12 | module.exports = TransformSystem;
13 |
--------------------------------------------------------------------------------
/transitions/perf/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/core/test/famousEngine/FamousEngine.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'init',
3 | 'setChannel',
4 | 'getChannel',
5 | '_update',
6 | 'requestUpdate',
7 | 'requestUpdateOnNextTick',
8 | 'handleMessage',
9 | 'handleWith',
10 | 'handleFrame',
11 | 'step',
12 | 'getContext',
13 | 'getClock',
14 | 'message',
15 | 'createScene',
16 | 'addScene',
17 | 'removeScene',
18 | 'startRenderLoop',
19 | 'stopRenderLoop',
20 | 'startEngine',
21 | 'stopEngine'
22 | ];
23 |
--------------------------------------------------------------------------------
/core/test/transform/Transform.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | 'reset',
3 | 'setParent',
4 | 'getParent',
5 | 'setBreakPoint',
6 | 'isBreakPoint',
7 | 'getLocalTransform',
8 | 'getWorldTransform',
9 | 'calculate',
10 | 'getPosition',
11 | 'setPosition',
12 | 'getRotation',
13 | 'setRotation',
14 | 'getScale',
15 | 'setScale',
16 | 'getAlign',
17 | 'setAlign',
18 | 'getMountPoint',
19 | 'setMountPoint',
20 | 'getOrigin',
21 | 'setOrigin',
22 | 'calculateWorldMatrix'
23 | ];
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '0.10'
4 | - 'iojs'
5 | addons:
6 | firefox: "38.0"
7 | before_install:
8 | - "export DISPLAY=:99.0"
9 | - "sh -e /etc/init.d/xvfb start"
10 | sudo: false
11 | script: npm test && npm run check-jsdoc && npm run lint
12 | notifications:
13 | email:
14 | - mike@famo.us
15 | - myles@famo.us
16 | - marianna@famo.us
17 | slack:
18 | secure: xy1hxUnULcBZxt3eGO8v/IUuIvvTUGZvMVaKeh/+gbutExlODJbav2i7tfzi71SynBCA483wTEh/RHX96hvhrS52kkJTXPq6b17pgGAbx549ouKD/8nzB0AW0THeLZY/dsWxS/T1MXtZMAabufv4Zh8+H5m6ZOo9DPNYsjD2URk=
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Famous Industries Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/core/test/pathStore/PathStore.helpers.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var helpers = {};
4 |
5 | var pathStub = null;
6 |
7 | helpers.setPathStub = function setPathStub (stub) {
8 | pathStub = stub;
9 | };
10 |
11 | helpers.InsertTester = function InsertTester (depth, index, path) {
12 | this.depth = depth;
13 | this.index = index;
14 | this.path = path;
15 |
16 | pathStub.depth.withArgs(path).returns(this.depth);
17 | pathStub.index.withArgs(path).returns(this.index);
18 | };
19 |
20 | helpers.InsertTester.prototype.isDeeperThan = function isDeeperThan (otherTester) {
21 | return this.depth > otherTester.depth;
22 | };
23 |
24 | helpers.InsertTester.prototype.isOfEqualDepthTo = function isOfEqualDepthTo (otherTester) {
25 | return this.depth === otherTester.depth;
26 | };
27 |
28 | helpers.InsertTester.prototype.hasAGreaterIndexThan = function hasAGreaterIndexThan (otherTester) {
29 | return this.index > otherTester.index;
30 | };
31 |
32 | helpers.InsertTester.prototype.isAfter = function isAfter (otherTester) {
33 | if (
34 | this.isDeeperThan(otherTester) ||
35 | (this.isOfEqualDepthTo(otherTester) &&
36 | this.hasAGreaterIndexThan(otherTester))
37 | ) return true;
38 | else return false;
39 | };
40 |
41 | module.exports = helpers;
42 |
43 |
--------------------------------------------------------------------------------
/dom-renderables/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | DOMElement: require('./DOMElement')
29 | };
30 |
--------------------------------------------------------------------------------
/transitions/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Curves: require('./Curves'),
29 | Transitionable: require('./Transitionable')
30 | };
31 |
--------------------------------------------------------------------------------
/webgl-materials/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Material: require('./Material'),
29 | TextureRegistry: require('./TextureRegistry')
30 | };
31 |
--------------------------------------------------------------------------------
/math/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | module.exports = {
26 | Mat33: require('./Mat33'),
27 | Quaternion: require('./Quaternion'),
28 | Vec2: require('./Vec2'),
29 | Vec3: require('./Vec3')
30 | };
31 |
32 |
--------------------------------------------------------------------------------
/webgl-renderables/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Mesh: require('./Mesh'),
29 | PointLight: require('./lights/PointLight'),
30 | AmbientLight: require('./lights/AmbientLight')
31 | };
32 |
--------------------------------------------------------------------------------
/core/test/node/Node.api.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | '_init',
3 | '_setParent',
4 | '_setMounted',
5 | '_setShown',
6 | '_setUpdater',
7 | 'getLocation',
8 | 'getId',
9 | 'getLocation',
10 | 'emit',
11 | 'sendDrawCommand',
12 | 'getValue',
13 | 'getComputedValue',
14 | 'getChildren',
15 | 'getRawChildren',
16 | 'getParent',
17 | 'requestUpdate',
18 | 'requestUpdateOnNextTick',
19 | 'isMounted',
20 | 'isShown',
21 | 'getOpacity',
22 | 'getMountPoint',
23 | 'getAlign',
24 | 'getOrigin',
25 | 'getPosition',
26 | 'getRotation',
27 | 'getScale',
28 | 'getSizeMode',
29 | 'getProportionalSize',
30 | 'getDifferentialSize',
31 | 'getAbsoluteSize',
32 | 'getRenderSize',
33 | 'getSize',
34 | 'getTransform',
35 | 'getUIEvents',
36 | 'addChild',
37 | 'removeChild',
38 | 'addComponent',
39 | 'getComponent',
40 | 'removeComponent',
41 | 'removeUIEvent',
42 | 'addUIEvent',
43 | '_requestUpdate',
44 | '_vecOptionalSet',
45 | 'show',
46 | 'hide',
47 | 'setAlign',
48 | 'setMountPoint',
49 | 'setOrigin',
50 | 'setPosition',
51 | 'setRotation',
52 | 'setScale',
53 | 'setOpacity',
54 | 'setSizeMode',
55 | 'setProportionalSize',
56 | 'setDifferentialSize',
57 | 'setAbsoluteSize',
58 | 'getFrame',
59 | 'getComponents',
60 | 'update',
61 | 'mount',
62 | 'dismount'
63 | ];
64 |
--------------------------------------------------------------------------------
/polyfills/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | requestAnimationFrame: require('./animationFrame').requestAnimationFrame,
29 | cancelAnimationFrame: require('./animationFrame').cancelAnimationFrame
30 | };
31 |
--------------------------------------------------------------------------------
/render-loops/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | RequestAnimationFrameLoop: require('./RequestAnimationFrameLoop'),
29 | ContainerLoop: require('./ContainerLoop'),
30 | now: require('./now')
31 | };
32 |
--------------------------------------------------------------------------------
/render-loops/now.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | 'use strict';
25 |
26 | // Polyfill for performance.now()
27 | var now = (window.performance && window.performance.now) ? function() {
28 | return window.performance.now();
29 | } : Date.now;
30 |
31 | module.exports = now;
32 |
--------------------------------------------------------------------------------
/renderers/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Compositor: require('./Compositor'),
29 | Context: require('./Context'),
30 | UIManager: require('./UIManager'),
31 | injectCSS: require('./inject-css')
32 | };
33 |
--------------------------------------------------------------------------------
/webgl-shaders/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var glslify = require('glslify');
28 |
29 | var shaders = {
30 | vertex: glslify('./VertexShader.glsl'),
31 | fragment: glslify('./FragmentShader.glsl')
32 | };
33 |
34 | module.exports = shaders;
35 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | Adnan Wahab
2 | Alexander Gugel
3 | Alexander Gugel
4 | Anne-Gaelle Colom
5 | Arkady Pevzner
6 | Ben Rowles
7 | Dan
8 | Dan Miller
9 | Daniel Miller
10 | DnMllr
11 | Farhad Ghayour
12 | Farhad Ghayour
13 | Felix Tripier
14 | GrG
15 | Hannah Howard
16 | Imti
17 | Joseph
18 | Joseph Carroll
19 | Joseph Orbegoso Pea
20 | Larry Gordon
21 | Marc Wilhite
22 | Marianna Bezler
23 | Marianna Bezler
24 | Matthew Trost
25 | Michael O'Brien
26 | Mike O'Brien
27 | Mike O'Brien
28 | Morgan Plant
29 | Myles Borins
30 | Myles Borins
31 | Pilwon Huh
32 | Rick Armbrust
33 | SWES
34 | Zack Brown
35 | ben
36 | felix
37 | joseph
38 | quack quack
39 | redwoodfavorite
40 | unknown
41 |
--------------------------------------------------------------------------------
/dom-renderers/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | DOMRenderer: require('./DOMRenderer'),
29 | ElementCache: require('./ElementCache'),
30 | Events: require('./events'),
31 | Math: require('./Math'),
32 | VoidElements: require('./VoidElements')
33 | };
34 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/lowpRandom.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Calculates a pseudorandom number
27 | *
28 | * @method random
29 | * @private
30 | *
31 | *
32 | */
33 |
34 | float random(vec2 co) {
35 | return fract(sin(dot(co.xy,vec2(12.9898,78.233))) * 43758.5453);
36 | }
37 |
38 | #pragma glslify: export(random)
39 |
--------------------------------------------------------------------------------
/core/test/expected/DefaultNodeSpec.json:
--------------------------------------------------------------------------------
1 | {
2 | "location": null,
3 | "showState": {
4 | "mounted": false,
5 | "shown": true,
6 | "opacity": 1
7 | },
8 | "offsets": {
9 | "mountPoint": {
10 | "0": 0,
11 | "1": 0,
12 | "2": 0
13 | },
14 | "align": {
15 | "0": 0,
16 | "1": 0,
17 | "2": 0
18 | },
19 | "origin": {
20 | "0": 0,
21 | "1": 0,
22 | "2": 0
23 | }
24 | },
25 | "vectors": {
26 | "position": {
27 | "0": 0,
28 | "1": 0,
29 | "2": 0
30 | },
31 | "rotation": {
32 | "0": 0,
33 | "1": 0,
34 | "2": 0,
35 | "3": 1
36 | },
37 | "scale": {
38 | "0": 1,
39 | "1": 1,
40 | "2": 1
41 | }
42 | },
43 | "size": {
44 | "sizeMode": {
45 | "0": 0,
46 | "1": 0,
47 | "2": 0
48 | },
49 | "proportional": {
50 | "0": 1,
51 | "1": 1,
52 | "2": 1
53 | },
54 | "differential": {
55 | "0": 0,
56 | "1": 0,
57 | "2": 0
58 | },
59 | "absolute": {
60 | "0": 0,
61 | "1": 0,
62 | "2": 0
63 | },
64 | "render": {
65 | "0": 0,
66 | "1": 0,
67 | "2": 0
68 | }
69 | },
70 | "UIEvents": []
71 | }
72 |
--------------------------------------------------------------------------------
/utilities/Registry.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | function Registry () {
4 | this._keyToValue = {};
5 | this._values = [];
6 | this._keys = [];
7 | this._keyToIndex = {};
8 | this._freedIndices = [];
9 | }
10 |
11 | Registry.prototype.register = function register (key, value) {
12 | var index = this._keyToIndex[key];
13 | if (index == null) {
14 | index = this._freedIndices.pop();
15 | if (index === undefined) index = this._values.length;
16 |
17 | this._values[index] = value;
18 | this._keys[index] = key;
19 |
20 | this._keyToIndex[key] = index;
21 | this._keyToValue[key] = value;
22 | }
23 | else {
24 | this._keyToValue[key] = value;
25 | this._values[index] = value;
26 | }
27 | };
28 |
29 | Registry.prototype.unregister = function unregister (key) {
30 | var index = this._keyToIndex[key];
31 |
32 | if (index != null) {
33 | this._freedIndices.push(index);
34 | this._keyToValue[key] = null;
35 | this._keyToIndex[key] = null;
36 | this._values[index] = null;
37 | this._keys[index] = null;
38 | }
39 | };
40 |
41 | Registry.prototype.get = function get (key) {
42 | return this._keyToValue[key];
43 | };
44 |
45 | Registry.prototype.getValues = function getValues () {
46 | return this._values;
47 | };
48 |
49 | Registry.prototype.getKeys = function getKeys () {
50 | return this._keys;
51 | };
52 |
53 | Registry.prototype.getKeyToValue = function getKeyToValue () {
54 | return this._keyToValue;
55 | };
56 |
57 | module.exports = Registry;
58 |
--------------------------------------------------------------------------------
/core/test/path/Path.helpers.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var helpers = {};
4 |
5 | helpers.generateSelector = function generateSelector () {
6 | return Math.random().toString(36).substring(2, 5);
7 | };
8 |
9 | helpers.makeID = function makeID (path) {
10 | return '#' + path;
11 | };
12 |
13 | helpers.makeClass = function makeClass (path) {
14 | return '.' + path;
15 | };
16 |
17 | helpers.generateIndex = function generateIndex() {
18 | return (Math.random() * 40)|0;
19 | };
20 |
21 | helpers.addDepth = function addDepth (path) {
22 | return path + '/' + this.generateIndex();
23 | };
24 |
25 | helpers.generatePathOfDepth = function generatePathOfDepth (depth) {
26 | var path = this.generateSelector();
27 | while (depth--) path = this.addDepth(path);
28 | return path;
29 | };
30 |
31 | helpers.generatePath = function generatePath () {
32 | return this.generatePathOfDepth((Math.random() * 6)|0);
33 | };
34 |
35 | helpers.generateTestCases = function generateTestCases () {
36 | var result = [];
37 | for (var i = 0 ; i < 10 ; i++) {
38 | result.push(this.generateSelector());
39 | result.push(this.makeID(this.generateSelector()));
40 | result.push(this.makeClass(this.generateSelector()));
41 | result.push(this.generatePath());
42 | result.push(this.makeID(this.generatePath()));
43 | result.push(this.makeClass(this.generatePath()));
44 | }
45 | return result;
46 | };
47 |
48 | helpers.addTrailingSlash = function addTrailingSlash (path) {
49 | return path + '/';
50 | };
51 |
52 | module.exports = helpers;
53 |
54 |
--------------------------------------------------------------------------------
/utilities/test/clamp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var clamp = require('../clamp');
29 |
30 | test('clamp', function(t) {
31 | t.equal(typeof clamp, 'function', 'clamp should be a function');
32 |
33 | t.equal(clamp(0, 1, 4), 1);
34 | t.equal(clamp(5, 1, 4), 4);
35 | t.equal(clamp(3, 1, 4), 3);
36 |
37 | t.end();
38 | });
39 |
--------------------------------------------------------------------------------
/utilities/test/KeyCodes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var KeyCodes = require('../KeyCodes');
29 |
30 | test('KeyCodes', function(t) {
31 | t.equal(typeof KeyCodes, 'object', 'KeyCodes should export an object');
32 | for (var key in KeyCodes) {
33 | t.equal(typeof KeyCodes[key], 'number', 'KeyCodes should be a flat object with number codes as values');
34 | }
35 | t.end();
36 | });
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/random.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Calculates a pseudorandom number
27 | *
28 | * @method random
29 | * @private
30 | *
31 | *
32 | */
33 |
34 | highp float random(vec2 co) {
35 | highp float a = 12.9898;
36 | highp float b = 78.233;
37 | highp float c = 43758.5453;
38 | highp float dt= dot(co.xy ,vec2(a,b));
39 | highp float sn= mod(dt,3.14);
40 | return fract(sin(sn) * c);
41 | }
42 |
43 | #pragma glslify: export(random)
44 |
--------------------------------------------------------------------------------
/webgl-renderables/test/MockColor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | function MockColor() {
28 | this._r = 1;
29 | this._g = 1;
30 | this._b = 1;
31 | }
32 |
33 | MockColor.prototype.getNormalizedRGB = function getNormalizedRGB() {
34 | return [this._r, this._g, this._b];
35 | };
36 |
37 | MockColor.prototype.getColor = function getColor(option) {
38 | return (option === 'hex') ? this.getNormalizedRGB() : '#ffffff';
39 | };
40 |
41 | module.exports = MockColor;
42 |
--------------------------------------------------------------------------------
/render-loops/test/now.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var now = require('../now');
29 |
30 | test('now', function(t) {
31 | t.equal(typeof now(), 'number', 'now() should return a number');
32 | var originalPerformance = window.performance;
33 | window.performance = {
34 | now: function() {
35 | return 123;
36 | }
37 | };
38 | t.equal(now(), 123);
39 | window.performance = originalPerformance;
40 | t.end();
41 | });
42 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "node": true
5 | },
6 | "rules": {
7 | // Possible Errors
8 | "comma-dangle": 1,
9 | "valid-jsdoc": 0, //Moved to a separate script check-jsdoc
10 | // Best Practices
11 | "block-scoped-var": 1,
12 | "curly": [0, "multi"],
13 | "dot-location": [0, "object"], //Too much noise for now, might consider to enable it as a warning later
14 | "eqeqeq": [2, "allow-null"],
15 | "no-loop-func": 0,
16 | "no-multi-spaces": 0,
17 | "no-self-compare": 1,
18 | // Strict Mode
19 | "strict": 1,
20 | // Variables
21 | "no-shadow": 0, //Too much noise from tests, might consider to enable it as a warning later
22 | "no-undefined": 0,
23 | "no-unused-vars": [2, {"vars": "all", "args": "none"}],
24 | "no-use-before-define": [0, "nofunc"],
25 | "no-new": 0,
26 | // Stylistic Issues
27 | "brace-style": [1, "stroustrup"],
28 | "camelcase": 0, //Too much noise from tests, might consider to enable it as a warning later
29 | "comma-spacing": [0, {"before": false, "after": true}], //Noise
30 | "consistent-this": [0, "_this"],
31 | "eol-last": 1,
32 | "key-spacing": 0,
33 | "new-cap": 0,
34 | "no-trailing-spaces": 0,
35 | "no-mixed-spaces-and-tabs": 0, //Too much noise for now, might consider to enable it as a warning later
36 | "no-underscore-dangle": 0,
37 | "quotes": [0, "single"], //Too much noise for now, might consider to enable it as a warning later
38 | "semi-spacing": 0, //Too much noise for now, might consider to enable it as a warning later
39 | "space-infix-ops": 0,
40 | "space-unary-ops": 0 //Too much noise for now, might consider to enable it as a warning later
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/components/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Align: require('./Align'),
29 | Camera: require('./Camera'),
30 | GestureHandler: require('./GestureHandler'),
31 | MountPoint: require('./MountPoint'),
32 | Opacity: require('./Opacity'),
33 | Origin: require('./Origin'),
34 | Position: require('./Position'),
35 | Rotation: require('./Rotation'),
36 | Scale: require('./Scale'),
37 | Size: require('./Size'),
38 | Transform: require('./Transform')
39 | };
40 |
--------------------------------------------------------------------------------
/dom-renderers/events/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | CompositionEvent: require('./CompositionEvent'),
29 | Event: require('./Event'),
30 | EventMap: require('./EventMap'),
31 | FocusEvent: require('./FocusEvent'),
32 | InputEvent: require('./InputEvent'),
33 | KeyboardEvent: require('./KeyboardEvent'),
34 | MouseEvent: require('./MouseEvent'),
35 | TouchEvent: require('./TouchEvent'),
36 | UIEvent: require('./UIEvent'),
37 | WheelEvent: require('./WheelEvent')
38 | };
39 |
40 |
--------------------------------------------------------------------------------
/utilities/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | CallbackStore: require('./CallbackStore'),
29 | clamp: require('./clamp'),
30 | clone: require('./clone'),
31 | Color: require('./Color'),
32 | KeyCodes: require('./KeyCodes'),
33 | keyValueToArrays: require('./keyValueToArrays'),
34 | loadURL: require('./loadURL'),
35 | ObjectManager: require('./ObjectManager'),
36 | Registry: require('./Registry'),
37 | strip: require('./strip'),
38 | vendorPrefix: require('./vendorPrefix')
39 | };
40 |
--------------------------------------------------------------------------------
/webgl-renderers/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Buffer: require('./Buffer'),
29 | BufferRegistry: require('./BufferRegistry'),
30 | compileMaterial: require('./compileMaterial'),
31 | createCheckerboard: require('./createCheckerboard'),
32 | Debug: require('./Debug'),
33 | Program: require('./Program'),
34 | radixSort: require('./radixSort'),
35 | Texture: require('./Texture'),
36 | TextureManager: require('./TextureManager'),
37 | WebGLRenderer: require('./WebGLRenderer')
38 | };
39 |
--------------------------------------------------------------------------------
/utilities/clamp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Returns a number guaranteed to be within the range [lower, upper].
29 | *
30 | * @method clamp
31 | *
32 | * @param {Number} value value to be processed by clamp
33 | * @param {Number} lower lower bound of the range
34 | * @param {Number} upper upper bound of the range
35 | * @return {Number} value between [lower, upper]
36 | */
37 | function clamp(value, lower, upper) {
38 | return value < lower ? lower : value > upper ? upper : value;
39 | }
40 |
41 | module.exports = clamp;
42 |
43 |
--------------------------------------------------------------------------------
/physics/test/bodies/Box.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Particle = require('../../bodies/Particle');
28 | var Box = require('../../bodies/Box');
29 | var test = require('tape');
30 |
31 | test('Box', function(t) {
32 | var b = new Box({size:[10,10,10]});
33 |
34 | t.test('should extend Particle', function(t) {
35 | t.assert(Box instanceof Function, 'Box should be a constructor');
36 |
37 | t.assert(b instanceof Box && b instanceof Particle, 'new boxes should be instances of Particle');
38 |
39 | t.end();
40 | });
41 |
42 | t.end();
43 | });
44 |
--------------------------------------------------------------------------------
/core/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Channel: require('./Channel'),
29 | Clock: require('./Clock'),
30 | Commands: require('./Commands'),
31 | Dispatch: require('./Dispatch'),
32 | Event: require('./Event'),
33 | FamousEngine: require('./FamousEngine'),
34 | Node: require('./Node'),
35 | Path: require('./Path'),
36 | PathStore: require('./PathStore'),
37 | Scene: require('./Scene'),
38 | Size: require('./Size'),
39 | SizeSystem: require('./SizeSystem'),
40 | Transform: require('./Transform'),
41 | TransformSystem: require('./TransformSystem')
42 | };
43 |
--------------------------------------------------------------------------------
/dom-renderers/VoidElements.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Map of void elements as defined by the
29 | * [HTML5 spec](http://www.w3.org/TR/html5/syntax.html#elements-0).
30 | *
31 | * @type {Object}
32 | */
33 | var VoidElements = {
34 | area : true,
35 | base : true,
36 | br : true,
37 | col : true,
38 | embed : true,
39 | hr : true,
40 | img : true,
41 | input : true,
42 | keygen: true,
43 | link : true,
44 | meta : true,
45 | param : true,
46 | source: true,
47 | track : true,
48 | wbr : true
49 | };
50 |
51 | module.exports = VoidElements;
52 |
--------------------------------------------------------------------------------
/utilities/test/vendorPrefix.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var vendorPrefix = require('../vendorPrefix');
29 |
30 | test('vendorPrefix', function(t) {
31 | t.notEqual(
32 | [
33 | 'transform',
34 | '-ms-transform',
35 | '-webkit-transform',
36 | '-moz-transform',
37 | '-o-transform'
38 | ].indexOf(vendorPrefix('transform')),
39 | -1,
40 | 'vendorPrefix(\"transform\" should evaluate to a vendor prefixed ' +
41 | 'version of the transform property)'
42 | );
43 |
44 | t.end();
45 | });
46 |
--------------------------------------------------------------------------------
/core/Event.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * The Event class adds the stopPropagation functionality
29 | * to the UIEvents within the scene graph.
30 | *
31 | * @constructor Event
32 | */
33 | function Event () {
34 | this.propagationStopped = false;
35 | this.stopPropagation = stopPropagation;
36 | }
37 |
38 | /**
39 | * stopPropagation ends the bubbling of the event in the
40 | * scene graph.
41 | *
42 | * @method stopPropagation
43 | *
44 | * @return {undefined} undefined
45 | */
46 | function stopPropagation () {
47 | this.propagationStopped = true;
48 | }
49 |
50 | module.exports = Event;
51 |
52 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/applyMaterial.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Placeholder for fragmentShader chunks to be templated in.
27 | * Used for normal mapping, gloss mapping and colors.
28 | *
29 | * @method applyMaterial
30 | * @private
31 | *
32 | *
33 | */
34 |
35 | #float_definitions
36 | float applyMaterial(float ID) {
37 | #float_applications
38 | return 1.;
39 | }
40 |
41 | #vec3_definitions
42 | vec3 applyMaterial(vec3 ID) {
43 | #vec3_applications
44 | return vec3(0);
45 | }
46 |
47 | #vec4_definitions
48 | vec4 applyMaterial(vec4 ID) {
49 | #vec4_applications
50 |
51 | return vec4(0);
52 | }
53 |
54 | #pragma glslify: export(applyMaterial)
55 |
--------------------------------------------------------------------------------
/utilities/loadURL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Load a URL and return its contents in a callback.
29 | *
30 | * @method loadURL
31 | * @memberof Utilities
32 | *
33 | * @param {String} url URL of object
34 | * @param {Function} callback callback to dispatch with content
35 | *
36 | * @return {undefined} undefined
37 | */
38 | var loadURL = function loadURL(url, callback) {
39 | var xhr = new XMLHttpRequest();
40 | xhr.onreadystatechange = function onreadystatechange() {
41 | if (this.readyState === 4) {
42 | if (callback) callback(this.responseText);
43 | }
44 | };
45 | xhr.open('GET', url);
46 | xhr.send();
47 | };
48 |
49 | module.exports = loadURL;
50 |
--------------------------------------------------------------------------------
/utilities/test/clone.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var clone = require('../clone');
29 |
30 | test('clone', function(t) {
31 | t.equal(typeof clone, 'function', 'clone should be a function');
32 |
33 | var flatObject = {a: {}, b: {}, c: {}};
34 | t.deepEqual(clone(flatObject), flatObject, 'clone should clone flat object');
35 |
36 | var nestedObject = {
37 | test1: {
38 | test1test1: {
39 | test1test1test1: 3
40 | },
41 | test1test2: 3
42 | },
43 | test2: {},
44 | test3: {}
45 | };
46 | t.deepEqual(clone(nestedObject), nestedObject, 'clone should deep clone nested object');
47 | t.end();
48 | });
49 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | module.exports = {
26 | components: require('./components'),
27 | core: require('./core'),
28 | renderLoops: require('./render-loops'),
29 | domRenderables: require('./dom-renderables'),
30 | domRenderers: require('./dom-renderers'),
31 | math: require('./math'),
32 | physics: require('./physics'),
33 | renderers: require('./renderers'),
34 | transitions: require('./transitions'),
35 | utilities: require('./utilities'),
36 | webglRenderables: require('./webgl-renderables'),
37 | webglRenderers: require('./webgl-renderers'),
38 | webglGeometries: require('./webgl-geometries'),
39 | webglMaterials: require('./webgl-materials'),
40 | webglShaders: require('./webgl-shaders'),
41 | polyfills: require('./polyfills')
42 | };
43 |
--------------------------------------------------------------------------------
/utilities/test/keyValueToArrays.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var keyValueToArrays = require('../keyValueToArrays');
29 |
30 | test('keyValueToArrays', function(t) {
31 | t.equal(
32 | typeof keyValueToArrays,
33 | 'function',
34 | 'keyValueToArrays should be a function'
35 | );
36 |
37 | var obj = Object.create({
38 | a: 1,
39 | b: 2,
40 | c: 3
41 | });
42 |
43 | obj.d = 4;
44 | obj.e = 5;
45 | obj.f = 6;
46 |
47 | t.deepEqual(
48 | keyValueToArrays(obj),
49 | {
50 | keys: ['d', 'e', 'f'],
51 | values: [4, 5, 6]
52 | },
53 | 'keyValueToArrays should only extract own properties'
54 | );
55 |
56 | t.end();
57 | });
58 |
--------------------------------------------------------------------------------
/webgl-geometries/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Box: require('./primitives/Box'),
29 | Circle: require('./primitives/Circle'),
30 | Cylinder: require('./primitives/Cylinder'),
31 | GeodesicSphere: require('./primitives/GeodesicSphere'),
32 | Icosahedron: require('./primitives/Icosahedron'),
33 | ParametricCone: require('./primitives/ParametricCone'),
34 | Plane: require('./primitives/Plane'),
35 | Sphere: require('./primitives/Sphere'),
36 | Tetrahedron: require('./primitives/Tetrahedron'),
37 | Torus: require('./primitives/Torus'),
38 | Triangle: require('./primitives/Triangle'),
39 | GeometryHelper: require('./GeometryHelper'),
40 | DynamicGeometry: require('./DynamicGeometry'),
41 | Geometry: require('./Geometry'),
42 | OBJLoader: require('./OBJLoader')
43 | };
44 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/transpose.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Reflects a matrix over its main diagonal.
27 | *
28 | * @method transpose
29 | * @private
30 | *
31 | *
32 | */
33 |
34 |
35 | float transpose(float m) {
36 | return m;
37 | }
38 |
39 | mat2 transpose(mat2 m) {
40 | return mat2(m[0][0], m[1][0],
41 | m[0][1], m[1][1]);
42 | }
43 |
44 | mat3 transpose(mat3 m) {
45 | return mat3(m[0][0], m[1][0], m[2][0],
46 | m[0][1], m[1][1], m[2][1],
47 | m[0][2], m[1][2], m[2][2]);
48 | }
49 |
50 | mat4 transpose(mat4 m) {
51 | return mat4(m[0][0], m[1][0], m[2][0], m[3][0],
52 | m[0][1], m[1][1], m[2][1], m[3][1],
53 | m[0][2], m[1][2], m[2][2], m[3][2],
54 | m[0][3], m[1][3], m[2][3], m[3][3]);
55 | }
56 |
57 | #pragma glslify: export(transpose)
58 |
--------------------------------------------------------------------------------
/core/test/helpers/MockNode.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | function MockNode (selector, receivedQueue) {
28 | this.children = [];
29 | this.selector = selector;
30 | this.receivedQueue = receivedQueue;
31 | }
32 |
33 | MockNode.prototype.getSelector = function getSelector () {
34 | return this.selector;
35 | };
36 |
37 | MockNode.prototype.getChildren = function getChildren () {
38 | return this.children;
39 | };
40 |
41 | MockNode.prototype.addChild = function addChild (receivedQueue) {
42 | var node = new MockNode(this.selector + '/' + this.children.length, receivedQueue);
43 | this.children.push(node);
44 | return node;
45 | };
46 |
47 | MockNode.prototype.getLocation = function getLocation () {
48 | return this.selector;
49 | };
50 |
51 | MockNode.prototype.onReceive = function () {
52 | this.receivedQueue.push(this);
53 | };
54 |
55 | module.exports = MockNode;
56 |
57 |
--------------------------------------------------------------------------------
/webgl-renderers/createCheckerboard.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Generates a checkerboard pattern to be used as a placeholder texture while
29 | * an image loads over the network.
30 | *
31 | * @method createCheckerBoard
32 | *
33 | * @return {HTMLCanvasElement} The `canvas` element that has been used in order
34 | * to generate the pattern.
35 | */
36 | function createCheckerBoard() {
37 | var context = document.createElement('canvas').getContext('2d');
38 | context.canvas.width = context.canvas.height = 128;
39 | for (var y = 0; y < context.canvas.height; y += 16) {
40 | for (var x = 0; x < context.canvas.width; x += 16) {
41 | context.fillStyle = (x ^ y) & 16 ? '#FFF' : '#DDD';
42 | context.fillRect(x, y, 16, 16);
43 | }
44 | }
45 |
46 | return context.canvas;
47 | }
48 |
49 | module.exports = createCheckerBoard;
50 |
--------------------------------------------------------------------------------
/physics/test/bodies/Wall.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Particle = require('../../bodies/Particle');
28 | var Wall = require('../../bodies/Wall');
29 | var test = require('tape');
30 |
31 | test('Wall', function(t) {
32 | var w = new Wall({direct: Wall.DOWN});
33 |
34 | t.test('should extend Particle', function(t) {
35 | t.assert(Wall instanceof Function, 'Wall should be a constructor');
36 |
37 | t.assert(w instanceof Wall && w instanceof Particle, 'new boxes should be instances of Particle');
38 |
39 | t.end();
40 | });
41 |
42 | t.test('mass properties', function(t) {
43 | t.assert(w.inverseMass === 0, 'walls should have 0 inverse mass');
44 | var i = w.inverseInertia.get();
45 | t.assert(i[0] === 0 && i[4] === 0 && i[8] === 0, 'walls should have 0 inverse moments of inertia');
46 |
47 | t.end();
48 | });
49 |
50 | t.end();
51 | });
52 |
--------------------------------------------------------------------------------
/core/test/Size.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var Size = require('../Size');
29 |
30 | test('Size', function(t) {
31 | t.test('constructor', function(t) {
32 | t.equal(typeof Size, 'function', 'Size should be a constructor function');
33 | t.doesNotThrow(function() {
34 | new Size();
35 | }, 'Size constructor should not throw an error');
36 | t.end();
37 | });
38 |
39 | t.test('enum', function(t) {
40 | t.notLooseEqual(Size.RELATIVE, null, 'Size.RELATIVE should be set');
41 | t.notLooseEqual(Size.ABSOLUTE, null, 'Size.ABSOLUTE should be set');
42 | t.notLooseEqual(Size.RENDER, null, 'Size.RENDER should be set');
43 | t.notLooseEqual(Size.DEFAULT, null, 'Size.DEFAULT should be set');
44 | t.end();
45 | });
46 |
47 | t.test('fromSpecWithParent method', function(t) {
48 | // TODO
49 |
50 | t.end();
51 | });
52 | });
53 |
--------------------------------------------------------------------------------
/webgl-renderables/lights/AmbientLight.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Light = require('./Light');
28 | var Commands = require('../../core/Commands');
29 |
30 | /**
31 | * AmbientLight extends the functionality of Light. It sets the ambience in
32 | * the scene. Ambience is a light source that emits light in the entire
33 | * scene, evenly.
34 | *
35 | * @class AmbientLight
36 | * @constructor
37 | * @augments Light
38 | *
39 | * @param {Node} node LocalDispatch to be retrieved from the corresponding Render Node
40 | *
41 | * @return {undefined} undefined
42 | */
43 | function AmbientLight(node) {
44 | Light.call(this, node);
45 | this.commands.color = Commands.GL_AMBIENT_LIGHT;
46 | }
47 |
48 | /**
49 | * Extends Light constructor
50 | */
51 | AmbientLight.prototype = Object.create(Light.prototype);
52 |
53 | /**
54 | * Sets AmbientLight as the constructor
55 | */
56 | AmbientLight.prototype.constructor = AmbientLight;
57 |
58 | module.exports = AmbientLight;
59 |
--------------------------------------------------------------------------------
/dom-renderers/events/FocusEvent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var UIEvent = require('./UIEvent');
28 |
29 | /**
30 | * See [UI Events (formerly DOM Level 3 Events)](http://www.w3.org/TR/2015/WD-uievents-20150428/#events-focusevent).
31 | *
32 | * @class FocusEvent
33 | * @augments UIEvent
34 | *
35 | * @param {Event} ev The native DOM event.
36 | */
37 | function FocusEvent(ev) {
38 | // [Constructor(DOMString typeArg, optional FocusEventInit focusEventInitDict)]
39 | // interface FocusEvent : UIEvent {
40 | // readonly attribute EventTarget? relatedTarget;
41 | // };
42 |
43 | UIEvent.call(this, ev);
44 | }
45 |
46 | FocusEvent.prototype = Object.create(UIEvent.prototype);
47 | FocusEvent.prototype.constructor = FocusEvent;
48 |
49 | /**
50 | * Return the name of the event type
51 | *
52 | * @method
53 | *
54 | * @return {String} Name of the event type
55 | */
56 | FocusEvent.prototype.toString = function toString () {
57 | return 'FocusEvent';
58 | };
59 |
60 | module.exports = FocusEvent;
61 |
--------------------------------------------------------------------------------
/utilities/vendorPrefix.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var PREFIXES = ['', '-ms-', '-webkit-', '-moz-', '-o-'];
28 |
29 | /**
30 | * A helper function used for determining the vendor prefixed version of the
31 | * passed in CSS property.
32 | *
33 | * Vendor checks are being conducted in the following order:
34 | *
35 | * 1. (no prefix)
36 | * 2. `-mz-`
37 | * 3. `-webkit-`
38 | * 4. `-moz-`
39 | * 5. `-o-`
40 | *
41 | * @method vendorPrefix
42 | *
43 | * @param {String} property CSS property (no camelCase), e.g.
44 | * `border-radius`.
45 | * @return {String} prefixed Vendor prefixed version of passed in CSS
46 | * property (e.g. `-webkit-border-radius`).
47 | */
48 | function vendorPrefix(property) {
49 | for (var i = 0; i < PREFIXES.length; i++) {
50 | var prefixed = PREFIXES[i] + property;
51 | if (document.documentElement.style[prefixed] === '') {
52 | return prefixed;
53 | }
54 | }
55 | return property;
56 | }
57 |
58 | module.exports = vendorPrefix;
59 |
--------------------------------------------------------------------------------
/utilities/clone.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Deep clone an object.
29 | *
30 | * @method clone
31 | *
32 | * @param {Object} b Object to be cloned.
33 | * @return {Object} a Cloned object (deep equality).
34 | */
35 | var clone = function clone(b) {
36 | var a;
37 | if (typeof b === 'object') {
38 | a = (b instanceof Array) ? [] : {};
39 | for (var key in b) {
40 | if (typeof b[key] === 'object' && b[key] !== null) {
41 | if (b[key] instanceof Array) {
42 | a[key] = new Array(b[key].length);
43 | for (var i = 0; i < b[key].length; i++) {
44 | a[key][i] = clone(b[key][i]);
45 | }
46 | }
47 | else {
48 | a[key] = clone(b[key]);
49 | }
50 | }
51 | else {
52 | a[key] = b[key];
53 | }
54 | }
55 | }
56 | else {
57 | a = b;
58 | }
59 | return a;
60 | };
61 |
62 | module.exports = clone;
63 |
--------------------------------------------------------------------------------
/utilities/test/ObjectManager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var ObjectManager = require('../ObjectManager');
29 |
30 | test('ObjectManager', function(t) {
31 | t.equal(
32 | typeof ObjectManager,
33 | 'object',
34 | 'ObjectManager should be a singleton'
35 | );
36 |
37 | function A() {}
38 | function B() {}
39 |
40 | t.equal(
41 | typeof ObjectManager.register,
42 | 'function',
43 | 'ObjectManager.register should be a function'
44 | );
45 | ObjectManager.register('A', A);
46 | ObjectManager.register('B', B);
47 |
48 | var a0 = ObjectManager.requestA();
49 | var a1 = ObjectManager.requestA();
50 |
51 | t.notEqual(
52 | a0,
53 | a1,
54 | 'Objects should not be allocated to multiple requesters'
55 | );
56 |
57 | ObjectManager.freeA(a0);
58 |
59 | var a0Rebirth = ObjectManager.requestA();
60 |
61 | t.equal(
62 | a0,
63 | a0Rebirth,
64 | 'Objects should be reused'
65 | );
66 |
67 | t.end();
68 | });
69 |
--------------------------------------------------------------------------------
/utilities/keyValueToArrays.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /**
4 | * The MIT License (MIT)
5 | *
6 | * Copyright (c) 2015 Famous Industries Inc.
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to deal
10 | * in the Software without restriction, including without limitation the rights
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | * THE SOFTWARE.
25 | */
26 |
27 | /**
28 | * Takes an object containing keys and values and returns an object
29 | * comprising two "associate" arrays, one with the keys and the other
30 | * with the values.
31 | *
32 | * @method keyValuesToArrays
33 | *
34 | * @param {Object} obj Objects where to extract keys and values
35 | * from.
36 | * @return {Object} result
37 | * {Array.} result.keys Keys of `result`, as returned by
38 | * `Object.keys()`
39 | * {Array} result.values Values of passed in object.
40 | */
41 | module.exports = function keyValuesToArrays(obj) {
42 | var keysArray = [], valuesArray = [];
43 | var i = 0;
44 | for(var key in obj) {
45 | if (obj.hasOwnProperty(key)) {
46 | keysArray[i] = key;
47 | valuesArray[i] = obj[key];
48 | i++;
49 | }
50 | }
51 | return {
52 | keys: keysArray,
53 | values: valuesArray
54 | };
55 | };
56 |
--------------------------------------------------------------------------------
/dom-renderers/events/UIEvent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Event = require('./Event');
28 |
29 | /**
30 | * See [UI Events (formerly DOM Level 3 Events)](http://www.w3.org/TR/2015/WD-uievents-20150428).
31 | *
32 | * @class UIEvent
33 | * @augments Event
34 | *
35 | * @param {Event} ev The native DOM event.
36 | */
37 | function UIEvent(ev) {
38 | // [Constructor(DOMString type, optional UIEventInit eventInitDict)]
39 | // interface UIEvent : Event {
40 | // readonly attribute Window? view;
41 | // readonly attribute long detail;
42 | // };
43 | Event.call(this, ev);
44 |
45 | /**
46 | * @name UIEvent#detail
47 | * @type Number
48 | */
49 | this.detail = ev.detail;
50 | }
51 |
52 | UIEvent.prototype = Object.create(Event.prototype);
53 | UIEvent.prototype.constructor = UIEvent;
54 |
55 | /**
56 | * Return the name of the event type
57 | *
58 | * @method
59 | *
60 | * @return {String} Name of the event type
61 | */
62 | UIEvent.prototype.toString = function toString () {
63 | return 'UIEvent';
64 | };
65 |
66 | module.exports = UIEvent;
67 |
--------------------------------------------------------------------------------
/webgl-geometries/test/Geometry.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 | var test = require('tape');
27 | var Geometry = require('../Geometry');
28 |
29 | test('Geometry', function(t) {
30 | t.test('constructor', function(t) {
31 | var geometry = new Geometry();
32 |
33 | t.ok(geometry.spec instanceof Object, 'should have a spec object');
34 | t.equal(geometry.spec.bufferNames.length, 0, 'should not have any vertex buffers by default');
35 | t.ok(geometry.spec.type === 'TRIANGLES', 'should have correct default draw style.');
36 |
37 | var indexValue = [[1, 2, 3]];
38 | var secondGeometry = new Geometry({
39 | buffers: [{ name: 'indices', data: indexValue, size: 1 }]
40 | });
41 |
42 | t.notEqual(geometry.spec.id, secondGeometry.spec.id, 'should have unique ID');
43 | t.ok(secondGeometry.spec.bufferNames.indexOf('indices') !== -1, 'should pass buffer names to geometry spec');
44 | t.ok(secondGeometry.spec.bufferValues.indexOf(indexValue) !== -1, 'should pass buffer values to geometry spec');
45 |
46 | t.end();
47 | });
48 |
49 | t.end();
50 | });
51 |
--------------------------------------------------------------------------------
/core/test/helpers/SizeTestCaseGenerator.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var testCases = [];
28 | for (var sizeModeX = 0; sizeModeX < 3; sizeModeX++) {
29 | for (var sizeModeY = 0; sizeModeY < 3; sizeModeY++) {
30 | for (var sizeModeZ = 0; sizeModeZ < 3; sizeModeZ++) {
31 | testCases.push({
32 | parentSize: [(Math.random() * 200) | 0, (Math.random() * 200) | 0, (Math.random() * 200) | 0],
33 | spec: {
34 | size: {
35 | sizeMode: [sizeModeX, sizeModeY, sizeModeZ],
36 | proportional: [(Math.random()*100 | 0)/100, (Math.random()*100 | 0)/100, (Math.random()*100 | 0)/100],
37 | differential: [(Math.random() * 100) | 0, (Math.random() * 100) | 0, (Math.random() * 100) | 0],
38 | absolute: [(Math.random() * 100) | 0, (Math.random() * 100) | 0, (Math.random() * 100) | 0]
39 | }
40 | },
41 | expectedResult: new Float32Array(3)
42 | });
43 | }
44 | }
45 | }
46 |
47 | console.log(JSON.stringify(testCases, null, 4));
48 |
--------------------------------------------------------------------------------
/physics/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | module.exports = {
28 | Particle: require('./bodies/Particle'),
29 | convexBodyFactory: require('./bodies/convexBodyFactory'),
30 | Box: require('./bodies/Box'),
31 | Sphere: require('./bodies/Sphere'),
32 | Wall: require('./bodies/Wall'),
33 |
34 | Constraint: require('./constraints/Constraint'),
35 | Angle: require('./constraints/Angle'),
36 | Collision: require('./constraints/Collision'),
37 | Direction: require('./constraints/Direction'),
38 | Distance: require('./constraints/Distance'),
39 | Curve: require('./constraints/Curve'),
40 | Hinge: require('./constraints/Hinge'),
41 | BallAndSocket: require('./constraints/BallAndSocket'),
42 |
43 | Force: require('./forces/Force'),
44 | Drag: require('./forces/Drag'),
45 | RotationalDrag: require('./forces/RotationalDrag'),
46 | Gravity1D: require('./forces/Gravity1D'),
47 | Gravity3D: require('./forces/Gravity3D'),
48 | Spring: require('./forces/Spring'),
49 | RotationalSpring: require('./forces/RotationalSpring'),
50 |
51 | PhysicsEngine: require('./PhysicsEngine'),
52 | Geometry: require('./Geometry')
53 | };
54 |
--------------------------------------------------------------------------------
/physics/bodies/Box.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Vec3 = require('../../math/Vec3');
28 | var convexBodyFactory = require('./convexBodyFactory');
29 |
30 | var _Box = convexBodyFactory([
31 | // Order: back-left, back-right, front-left, front-right
32 | // Top half
33 | new Vec3(-100, -100, -100),
34 | new Vec3(100, -100, -100),
35 | new Vec3(-100, -100, 100),
36 | new Vec3(100, -100, 100),
37 | // Bottom half
38 | new Vec3(-100, 100, -100),
39 | new Vec3(100, 100, -100),
40 | new Vec3(-100, 100, 100),
41 | new Vec3(100, 100, 100)
42 | ]);
43 |
44 | /**
45 | * @class Box
46 | * @extends Particle
47 | * @param {Object} options Initial state of the body.
48 | */
49 | function Box(options) {
50 | _Box.call(this, options);
51 | this.normals = [
52 | // Order: top, right, front
53 | new Vec3(0, 1, 0),
54 | new Vec3(1, 0, 0),
55 | new Vec3(0, 0, 1)
56 | ];
57 |
58 | this.type = 1 << 1;
59 | }
60 |
61 | Box.prototype = Object.create(_Box.prototype);
62 | Box.prototype.constructor = Box;
63 |
64 | module.exports = Box;
65 |
--------------------------------------------------------------------------------
/webgl-renderers/test/radixSort.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 | var test = require('tape');
27 | var radixSort = require('../radixSort');
28 |
29 | test('radixSort', function(t) {
30 | var registry = {};
31 | var meshList = [];
32 | while (meshList.length < 1e3) {
33 | var path = Math.random();
34 | registry[path] = mockMesh();
35 | meshList[meshList.length] = path;
36 | }
37 |
38 | radixSort(meshList, registry);
39 |
40 | t.test('sort', function(t) {
41 | t.equals(checkSorted(meshList), true, 'should be sorted by depth');
42 |
43 | t.end();
44 | });
45 |
46 | t.end();
47 | });
48 |
49 | function checkSorted (list, registry){
50 | var a, b;
51 | for (var i= 0; i < test.length - 1; i++) {
52 | a = list[i].uniformValues[1][14];
53 | b = list[i+1].uniformValues[1][14];
54 | if (a < b) return false;
55 | }
56 | return true;
57 | }
58 |
59 |
60 | function mockMesh () {
61 | return {
62 | uniformValues: [0, fakeTransform()]
63 | };
64 | }
65 |
66 | function fakeTransform() {
67 | var x = new Array(14);
68 | x[14] = Math.random() * 1000 + Math.random();
69 | return x;
70 | }
71 |
--------------------------------------------------------------------------------
/physics/test/forces/Force.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Force = require('../../forces/Force');
28 | var test = require('tape');
29 |
30 | test('Force', function(t) {
31 | var f = new Force();
32 |
33 | t.test('should be a constructor', function(t) {
34 | t.assert(Force instanceof Function, 'Force should be a function');
35 |
36 | t.assert(Object.keys(f).length !== 0, 'Force should be a construcor');
37 |
38 | t.end();
39 | });
40 |
41 | t.test('virtual prototypal methods', function(t) {
42 | t.assert(f.setOptions instanceof Function, '.setOptions should be a function');
43 | t.assert(f.init instanceof Function, '.init should be a function');
44 | t.assert(f.update instanceof Function, '.update should be a function');
45 |
46 | var initCalled = false;
47 | f.init = function() {
48 | initCalled = true;
49 | };
50 | var opts = {test1: 123, test2: 'abc'};
51 | f.setOptions(opts);
52 |
53 | t.assert(f.test1 === 123 && f.test2 === 'abc' && initCalled, '.setOptions should decorate the instance and then call .init');
54 |
55 | t.end();
56 | });
57 |
58 | t.end();
59 | });
60 |
--------------------------------------------------------------------------------
/dom-renderers/events/CompositionEvent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var UIEvent = require('./UIEvent');
28 |
29 | /**
30 | * See [UI Events (formerly DOM Level 3 Events)](http://www.w3.org/TR/2015/WD-uievents-20150428/#events-compositionevents).
31 | *
32 | * @class CompositionEvent
33 | * @augments UIEvent
34 | *
35 | * @param {Event} ev The native DOM event.
36 | */
37 | function CompositionEvent(ev) {
38 | // [Constructor(DOMString typeArg, optional CompositionEventInit compositionEventInitDict)]
39 | // interface CompositionEvent : UIEvent {
40 | // readonly attribute DOMString data;
41 | // };
42 |
43 | UIEvent.call(this, ev);
44 |
45 | /**
46 | * @name CompositionEvent#data
47 | * @type String
48 | */
49 | this.data = ev.data;
50 | }
51 |
52 | CompositionEvent.prototype = Object.create(UIEvent.prototype);
53 | CompositionEvent.prototype.constructor = CompositionEvent;
54 |
55 | /**
56 | * Return the name of the event type
57 | *
58 | * @method
59 | *
60 | * @return {String} Name of the event type
61 | */
62 | CompositionEvent.prototype.toString = function toString () {
63 | return 'CompositionEvent';
64 | };
65 |
66 | module.exports = CompositionEvent;
67 |
--------------------------------------------------------------------------------
/webgl-shaders/FragmentShader.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | #pragma glslify: applyMaterial = require(./chunks/applyMaterial)
26 | #pragma glslify: applyLight = require(./chunks/applyLight)
27 |
28 |
29 | /**
30 | * Writes the color of the pixel onto the screen
31 | *
32 | * @method main
33 | * @private
34 | *
35 | *
36 | */
37 | void main() {
38 | vec4 material = u_baseColor.r >= 0.0 ? u_baseColor : applyMaterial(u_baseColor);
39 |
40 | /**
41 | * Apply lights only if flat shading is false
42 | * and at least one light is added to the scene
43 | */
44 | bool lightsEnabled = (u_flatShading == 0.0) && (u_numLights > 0.0 || length(u_ambientLight) > 0.0);
45 |
46 | vec3 normal = normalize(v_normal);
47 | vec4 glossiness = u_glossiness.x < 0.0 ? applyMaterial(u_glossiness) : u_glossiness;
48 |
49 | vec4 color = lightsEnabled ?
50 | applyLight(material, normalize(v_normal), glossiness,
51 | int(u_numLights),
52 | u_ambientLight * u_baseColor.rgb,
53 | normalize(v_eyeVector),
54 | u_lightPosition,
55 | u_lightColor,
56 | v_position)
57 | : material;
58 |
59 | gl_FragColor = color;
60 | gl_FragColor.a *= u_opacity;
61 | }
62 |
--------------------------------------------------------------------------------
/utilities/strip.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Removes all non-primitive values from a (nested) object.
29 | *
30 | * Used for makeing arbitrary objects serializable through the structured
31 | * cloning algorithm used by `postMessage`.
32 | *
33 | * Supported primitives: `null`, `undefined`, `Boolean`, `Number`, `String`
34 | *
35 | * @method strip
36 | *
37 | * @param {*} obj A primitive or (non-)serializable object without
38 | * circular references.
39 | * @return {*} strippedObj A primitive or (nested) object only containing
40 | * primitive types (serializable).
41 | */
42 | function strip(obj) {
43 | switch (obj) {
44 | case null:
45 | case undefined:
46 | return obj;
47 | }
48 | switch (obj.constructor) {
49 | case Boolean:
50 | case Number:
51 | case String:
52 | return obj;
53 | case Object:
54 | for (var key in obj) {
55 | var stripped = strip(obj[key], true);
56 | obj[key] = stripped;
57 | }
58 | return obj;
59 | default:
60 | return null;
61 | }
62 | }
63 |
64 | module.exports = strip;
65 |
--------------------------------------------------------------------------------
/webgl-geometries/Geometry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var GeometryIds = 0;
28 |
29 | /**
30 | * Geometry is a component that defines and manages data
31 | * (vertex data and attributes) that is used to draw to WebGL.
32 | *
33 | * @class Geometry
34 | * @constructor
35 | *
36 | * @param {Object} options instantiation options
37 | * @return {undefined} undefined
38 | */
39 | function Geometry(options) {
40 | this.options = options || {};
41 | this.DEFAULT_BUFFER_SIZE = 3;
42 |
43 | this.spec = {
44 | id: GeometryIds++,
45 | dynamic: false,
46 | type: this.options.type || 'TRIANGLES',
47 | bufferNames: [],
48 | bufferValues: [],
49 | bufferSpacings: [],
50 | invalidations: []
51 | };
52 |
53 | if (this.options.buffers) {
54 | var len = this.options.buffers.length;
55 | for (var i = 0; i < len;) {
56 | this.spec.bufferNames.push(this.options.buffers[i].name);
57 | this.spec.bufferValues.push(this.options.buffers[i].data);
58 | this.spec.bufferSpacings.push(this.options.buffers[i].size || this.DEFAULT_BUFFER_SIZE);
59 | this.spec.invalidations.push(i++);
60 | }
61 | }
62 | }
63 |
64 | module.exports = Geometry;
65 |
--------------------------------------------------------------------------------
/components/Scale.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Position = require('./Position');
28 |
29 | /**
30 | * Scale is a component that allows the tweening of a Node's scale. Scale
31 | * happens about a Node's origin which is by default [0, 0, .5].
32 | *
33 | * @class Scale
34 | * @augments Position
35 | *
36 | * @param {Node} node Node that the Scale component will be attached to
37 | */
38 | function Scale(node) {
39 | Position.call(this, node);
40 |
41 | this._x.set(1);
42 | this._y.set(1);
43 | this._z.set(1);
44 | }
45 |
46 | /**
47 | * Return the name of the Scale component
48 | *
49 | * @method
50 | *
51 | * @return {String} Name of the component
52 | */
53 | Scale.prototype.toString = function toString() {
54 | return 'Scale';
55 | };
56 |
57 | Scale.prototype = Object.create(Position.prototype);
58 | Scale.prototype.constructor = Scale;
59 |
60 | /**
61 | * When the node this component is attached to updates, update the value
62 | * of the Node's scale.
63 | *
64 | * @method
65 | *
66 | * @return {undefined} undefined
67 | */
68 | Scale.prototype.update = function update() {
69 | this._node.setScale(this._x.get(), this._y.get(), this._z.get());
70 | this._checkUpdate();
71 | };
72 |
73 | Scale.prototype.onUpdate = Scale.prototype.update;
74 |
75 | module.exports = Scale;
76 |
--------------------------------------------------------------------------------
/physics/test/constraints/Constraint.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Constraint = require('../../constraints/Constraint');
28 | var test = require('tape');
29 |
30 | test('Constraint', function(t) {
31 | var c = new Constraint();
32 |
33 | t.test('should be a constructor', function(t) {
34 | t.assert(Constraint instanceof Function, 'Constraint should be a function');
35 |
36 | t.assert(Object.keys(c).length !== 0, 'Constraint should be a construcor');
37 |
38 | t.end();
39 | });
40 |
41 | t.test('virtual prototypal methods', function(t) {
42 | t.assert(c.setOptions instanceof Function, '.setOptions should be a function');
43 | t.assert(c.init instanceof Function, '.init should be a function');
44 | t.assert(c.update instanceof Function, '.update should be a function');
45 | t.assert(c.resolve instanceof Function, '.resolve should be a function');
46 |
47 | var initCalled = false;
48 | c.init = function() {
49 | initCalled = true;
50 | };
51 | var opts = {test1: 123, test2: 'abc'};
52 | c.setOptions(opts);
53 |
54 | t.assert(c.test1 === 123 && c.test2 === 'abc' && initCalled, '.setOptions should decorate the instance and then call .init');
55 |
56 | t.end();
57 | });
58 |
59 | t.end();
60 | });
61 |
--------------------------------------------------------------------------------
/dom-renderers/ElementCache.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var VoidElements = require('./VoidElements');
28 |
29 | /**
30 | * ElementCache is being used for keeping track of an element's DOM Element,
31 | * path, world transform, inverted parent, final transform (as being used for
32 | * setting the actual `transform`-property) and post render size (final size as
33 | * being rendered to the DOM).
34 | *
35 | * @class ElementCache
36 | *
37 | * @param {Element} element DOMElement
38 | * @param {String} path Path used for uniquely identifying the location in the
39 | * scene graph.
40 | */
41 | function ElementCache (element, path) {
42 | this.tagName = element.tagName.toLowerCase();
43 | this.void = VoidElements[this.tagName];
44 |
45 | var constructor = element.constructor;
46 |
47 | this.formElement = constructor === HTMLInputElement ||
48 | constructor === HTMLTextAreaElement ||
49 | constructor === HTMLSelectElement;
50 |
51 | this.element = element;
52 | this.path = path;
53 | this.content = null;
54 | this.size = new Int16Array(3);
55 | this.explicitHeight = false;
56 | this.explicitWidth = false;
57 | this.postRenderSize = new Float32Array(2);
58 | this.listeners = {};
59 | this.preventDefault = {};
60 | this.subscribe = {};
61 | }
62 |
63 | module.exports = ElementCache;
64 |
--------------------------------------------------------------------------------
/components/Align.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Position = require('./Position');
28 |
29 | /**
30 | * Align is a component designed to allow for smooth tweening
31 | * of the alignment of a node relative to its parent.
32 | *
33 | * @class Align
34 | * @augments Position
35 | *
36 | * @param {Node} node Node that the Align component will be attached to
37 | */
38 | function Align(node) {
39 | Position.call(this, node);
40 |
41 | var initial = node.getAlign();
42 |
43 | this._x.set(initial[0]);
44 | this._y.set(initial[1]);
45 | this._z.set(initial[2]);
46 | }
47 |
48 | /**
49 | * Return the name of the Align component
50 | *
51 | * @method
52 | *
53 | * @return {String} Name of the component
54 | */
55 | Align.prototype.toString = function toString() {
56 | return 'Align';
57 | };
58 |
59 | Align.prototype = Object.create(Position.prototype);
60 | Align.prototype.constructor = Align;
61 |
62 | /**
63 | * When the node this component is attached to updates, update the value
64 | * of the Node's align.
65 | *
66 | * @method
67 | *
68 | * @return {undefined} undefined
69 | */
70 | Align.prototype.update = function update() {
71 | this._node.setAlign(this._x.get(), this._y.get(), this._z.get());
72 | this._checkUpdate();
73 | };
74 |
75 | Align.prototype.onUpdate = Align.prototype.update;
76 |
77 | module.exports = Align;
78 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/applyLight.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Calculates the intensity of light on a surface.
27 | *
28 | * @method applyLight
29 | * @private
30 | *
31 | */
32 | vec4 applyLight(in vec4 baseColor, in vec3 normal, in vec4 glossiness, int numLights, vec3 ambientColor, vec3 eyeVector, mat4 lightPosition, mat4 lightColor, vec3 v_position) {
33 | vec3 diffuse = vec3(0.0);
34 | bool hasGlossiness = glossiness.a > 0.0;
35 | bool hasSpecularColor = length(glossiness.rgb) > 0.0;
36 |
37 | for(int i = 0; i < 4; i++) {
38 | if (i >= numLights) break;
39 | vec3 lightDirection = normalize(lightPosition[i].xyz - v_position);
40 | float lambertian = max(dot(lightDirection, normal), 0.0);
41 |
42 | if (lambertian > 0.0) {
43 | diffuse += lightColor[i].rgb * baseColor.rgb * lambertian;
44 | if (hasGlossiness) {
45 | vec3 halfVector = normalize(lightDirection + eyeVector);
46 | float specularWeight = pow(max(dot(halfVector, normal), 0.0), glossiness.a);
47 | vec3 specularColor = hasSpecularColor ? glossiness.rgb : lightColor[i].rgb;
48 | diffuse += specularColor * specularWeight * lambertian;
49 | }
50 | }
51 |
52 | }
53 |
54 | return vec4(ambientColor + diffuse, baseColor.a);
55 | }
56 |
57 | #pragma glslify: export(applyLight)
58 |
--------------------------------------------------------------------------------
/components/Origin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Position = require('./Position');
28 |
29 | /**
30 | * Origin is a component designed to allow for smooth tweening
31 | * of where on the Node should be considered the origin for rotations and scales.
32 | *
33 | * @class Origin
34 | * @augments Position
35 | *
36 | * @param {Node} node Node that the Origin component will be attached to
37 | */
38 | function Origin(node) {
39 | Position.call(this, node);
40 |
41 | var initial = node.getOrigin();
42 |
43 | this._x.set(initial[0]);
44 | this._y.set(initial[1]);
45 | this._z.set(initial[2]);
46 | }
47 |
48 | /**
49 | * Return the name of the Origin component
50 | *
51 | * @method
52 | *
53 | * @return {String} Name of the component
54 | */
55 | Origin.prototype.toString = function toString() {
56 | return 'Origin';
57 | };
58 |
59 | Origin.prototype = Object.create(Position.prototype);
60 | Origin.prototype.constructor = Origin;
61 |
62 | /**
63 | * When the node this component is attached to updates, update the value
64 | * of the Node's origin
65 | *
66 | * @method
67 | *
68 | * @return {undefined} undefined
69 | */
70 | Origin.prototype.update = function update() {
71 | this._node.setOrigin(this._x.get(), this._y.get(), this._z.get());
72 | this._checkUpdate();
73 | };
74 |
75 | Origin.prototype.onUpdate = Origin.prototype.update;
76 |
77 | module.exports = Origin;
78 |
--------------------------------------------------------------------------------
/components/MountPoint.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Position = require('./Position');
28 |
29 | /**
30 | * MountPoint is a component designed to allow for smooth tweening
31 | * of where on the Node it is attached to the parent.
32 | *
33 | * @class MountPoint
34 | * @augments Position
35 | *
36 | * @param {Node} node Node that the MountPoint component will be attached to
37 | */
38 | function MountPoint(node) {
39 | Position.call(this, node);
40 |
41 | var initial = node.getMountPoint();
42 |
43 | this._x.set(initial[0]);
44 | this._y.set(initial[1]);
45 | this._z.set(initial[2]);
46 | }
47 |
48 | /**
49 | * Return the name of the MountPoint component
50 | *
51 | * @method
52 | *
53 | * @return {String} Name of the component
54 | */
55 | MountPoint.prototype.toString = function toString() {
56 | return 'MountPoint';
57 | };
58 |
59 | MountPoint.prototype = Object.create(Position.prototype);
60 | MountPoint.prototype.constructor = MountPoint;
61 |
62 | /**
63 | * When the node this component is attached to updates, update the value
64 | * of the Node's mount point.
65 | *
66 | * @method
67 | *
68 | * @return {undefined} undefined
69 | */
70 | MountPoint.prototype.update = function update() {
71 | this._node.setMountPoint(this._x.get(), this._y.get(), this._z.get());
72 | this._checkUpdate();
73 | };
74 |
75 | MountPoint.prototype.onUpdate = MountPoint.prototype.update;
76 |
77 | module.exports = MountPoint;
78 |
--------------------------------------------------------------------------------
/transitions/test/Curves.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var curves = require('../Curves');
29 |
30 | test('Curves', function(t) {
31 | var curveNames = [
32 | 'linear',
33 | 'easeIn',
34 | 'easeOut',
35 | 'easeInOut',
36 | 'easeOutBounce',
37 | 'spring',
38 | 'inQuad',
39 | 'outQuad',
40 | 'inOutQuad',
41 | 'inCubic',
42 | 'outCubic',
43 | 'inOutCubic',
44 | 'inQuart',
45 | 'outQuart',
46 | 'inOutQuart',
47 | 'inQuint',
48 | 'outQuint',
49 | 'inOutQuint',
50 | 'inSine',
51 | 'outSine',
52 | 'inOutSine',
53 | 'inExpo',
54 | 'outExpo',
55 | 'inOutExpo',
56 | 'inCirc',
57 | 'outCirc',
58 | 'inOutCirc',
59 | 'inElastic',
60 | 'outElastic',
61 | 'inOutElastic',
62 | 'inBounce',
63 | 'outBounce',
64 | 'inOutBounce'
65 | ];
66 |
67 | for (var i = 0; i < curveNames.length; i++) {
68 | var name = curveNames[i];
69 | var curve = curves[name];
70 | t.equal(typeof curve, 'function', name + ' should be a default curve');
71 |
72 | t.equal(Math.round(curve(0)*1000)/1000, 0, 'Curves.' + name + ' should start with 0');
73 | t.equal(Math.round(curve(1)*1000)/1000, 1, 'Curves.' + name + ' should end with 1');
74 | }
75 |
76 | t.end();
77 | });
78 |
--------------------------------------------------------------------------------
/utilities/KeyCodes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Collection to map keyboard codes in plain english
29 | *
30 | * @class KeyCodes
31 | * @static
32 | */
33 | module.exports = {
34 | 0: 48,
35 | 1: 49,
36 | 2: 50,
37 | 3: 51,
38 | 4: 52,
39 | 5: 53,
40 | 6: 54,
41 | 7: 55,
42 | 8: 56,
43 | 9: 57,
44 | a: 97,
45 | b: 98,
46 | c: 99,
47 | d: 100,
48 | e: 101,
49 | f: 102,
50 | g: 103,
51 | h: 104,
52 | i: 105,
53 | j: 106,
54 | k: 107,
55 | l: 108,
56 | m: 109,
57 | n: 110,
58 | o: 111,
59 | p: 112,
60 | q: 113,
61 | r: 114,
62 | s: 115,
63 | t: 116,
64 | u: 117,
65 | v: 118,
66 | w: 119,
67 | x: 120,
68 | y: 121,
69 | z: 122,
70 | A: 65,
71 | B: 66,
72 | C: 67,
73 | D: 68,
74 | E: 69,
75 | F: 70,
76 | G: 71,
77 | H: 72,
78 | I: 73,
79 | J: 74,
80 | K: 75,
81 | L: 76,
82 | M: 77,
83 | N: 78,
84 | O: 79,
85 | P: 80,
86 | Q: 81,
87 | R: 82,
88 | S: 83,
89 | T: 84,
90 | U: 85,
91 | V: 86,
92 | W: 87,
93 | X: 88,
94 | Y: 89,
95 | Z: 90,
96 | ENTER : 13,
97 | LEFT_ARROW: 37,
98 | RIGHT_ARROW: 39,
99 | UP_ARROW: 38,
100 | DOWN_ARROW: 40,
101 | SPACE: 32,
102 | SHIFT: 16,
103 | TAB: 9
104 | };
105 |
106 |
--------------------------------------------------------------------------------
/webgl-renderers/test/createCheckerBoard.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 | var test = require('tape');
27 | var createCheckerboard = require('../createCheckerboard');
28 |
29 | var grey = 221;
30 | var white = 255;
31 | var avg = (255 + 221) / 2;
32 | var size = 128;
33 |
34 | test('createCheckerboard', function(t) {
35 |
36 | //the average color in the loading screen should be 238
37 |
38 | t.test('data', function (t) {
39 | var checkerboard = createCheckerboard();
40 | var ctx = checkerboard.getContext('2d');
41 |
42 | var rgb = ctx.getImageData(0, 0, size, size).data;
43 |
44 | var average = 0;
45 | for (var idx = 0; idx < 8188; idx += 4) {
46 | average += rgb[idx] + rgb[idx+1] + rgb[idx+2];
47 | var wrongColor = rgb[idx] !== white && rgb[idx] !== grey;
48 | var chooseColor = ((idx / 4) & 16) ? grey: white;
49 | var wrongLocation = rgb[idx] === chooseColor;
50 | var monochrome = rgb[idx] === rgb[idx + 1] === rgb[idx+2];
51 | if (monochrome) return t.ok(false, 'the color is wrong');
52 | if (wrongColor) return t.ok(false, 'the color is not white or grey');
53 | if (wrongLocation) return t.ok(false, 'the color is not alternating by 16');
54 | }
55 | t.ok(avg - (average / (8188 /4 ) / 3) < 1, 'the average color will be exactly beteween white and grey');
56 |
57 | t.end();
58 | });
59 | t.end();
60 | });
61 |
--------------------------------------------------------------------------------
/core/test/event/Event.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Event = require('../../Event');
28 | var test = require('tape');
29 |
30 | test('Event', function (t) {
31 | t.test('constructor', function (t) {
32 | t.doesNotThrow(function () {
33 | new Event();
34 | }, 'Event should be a constructor');
35 |
36 | var e = new Event();
37 |
38 | t.ok(
39 | e.propagationStopped != null && e.propagationStopped.constructor === Boolean,
40 | 'Event should have a propagationStopped property that is a boolean'
41 | );
42 |
43 | t.ok(
44 | !(e.propagationStopped),
45 | 'The propagationStopped property should be false by default'
46 | );
47 |
48 | t.ok(
49 | e.propagationStopped != null && e.stopPropagation.constructor === Function,
50 | 'Event should have a stopPropagation method'
51 | );
52 |
53 | t.end();
54 | });
55 |
56 | t.test('stopPropagation method', function (t) {
57 | var e = new Event();
58 |
59 | t.doesNotThrow(function () {
60 | new Event().stopPropagation();
61 | }, 'stopPropagation should call without error');
62 |
63 | e.stopPropagation();
64 |
65 | t.ok(
66 | e.propagationStopped,
67 | 'calling stopPropagation should set the propagationStopped property to false'
68 | );
69 |
70 | t.end();
71 | });
72 |
73 | });
74 |
--------------------------------------------------------------------------------
/renderers/test/Context.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var test = require('tape');
28 | var Context = require('../Context');
29 |
30 | var noop = function() {};
31 |
32 | test('Context', function(t) {
33 | t.test('constructor', function(t) {
34 | t.plan(3);
35 |
36 | t.equal(
37 | typeof Context,
38 | 'function',
39 | 'Context should b a constructor function'
40 | );
41 |
42 | new Context('body', {
43 | sendResize: function(selector, size) {
44 | t.equal(selector, 'body', 'Context should sendResize with selector');
45 | t.ok(size instanceof Array && size.length === 3, 'Context should send size as an array with three elements');
46 | }
47 | });
48 | });
49 |
50 | t.test('draw method', function(t) {
51 | var context = new Context('body', {
52 | sendResize: noop
53 | });
54 |
55 | context._domRenderer = {
56 | draw: function() {
57 | this.wasDrawn = true;
58 | }
59 | };
60 |
61 | context._webGLRenderer = {
62 | draw: function() {
63 | this.wasDrawn = true;
64 | }
65 | };
66 |
67 | context.draw();
68 |
69 | t.ok(context._domRenderer.wasDrawn, 'Should call draw on the DOMRenderer');
70 | t.ok(context._webGLRenderer.wasDrawn, 'Should call draw on the WebGLRenderer');
71 |
72 | t.end();
73 | });
74 | });
75 |
--------------------------------------------------------------------------------
/webgl-geometries/primitives/Triangle.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Geometry = require('../Geometry');
28 | var GeometryHelper = require('../GeometryHelper');
29 |
30 | /**
31 | * This function returns a new static geometry, which is passed
32 | * custom buffer data.
33 | *
34 | * @class Triangle
35 | * @constructor
36 | *
37 | * @param {Object} options Parameters that alter the
38 | * vertex buffers of the generated geometry.
39 | *
40 | * @return {Object} constructed geometry
41 | */
42 | function Triangle (options) {
43 | options = options || {};
44 | var detail = options.detail || 1;
45 | var normals = [];
46 | var textureCoords = [
47 | 0.0, 0.0,
48 | 0.5, 1.0,
49 | 1.0, 0.0
50 | ];
51 | var indices = [
52 | 0, 1, 2
53 | ];
54 | var vertices = [
55 | -1, -1, 0,
56 | 0, 1, 0,
57 | 1, -1, 0
58 | ];
59 |
60 | while(--detail) GeometryHelper.subdivide(indices, vertices, textureCoords);
61 |
62 | if (options.backface !== false) {
63 | GeometryHelper.addBackfaceTriangles(vertices, indices);
64 | }
65 |
66 | normals = GeometryHelper.computeNormals(vertices, indices);
67 |
68 | options.buffers = [
69 | { name: 'a_pos', data: vertices },
70 | { name: 'a_texCoord', data: textureCoords, size: 2 },
71 | { name: 'a_normals', data: normals },
72 | { name: 'indices', data: indices, size: 1 }
73 | ];
74 |
75 | return new Geometry(options);
76 | }
77 |
78 | module.exports = Triangle;
79 |
--------------------------------------------------------------------------------
/webgl-renderers/Buffer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /**
28 | * Buffer is a private class that wraps the vertex data that defines
29 | * the the points of the triangles that webgl draws. Each buffer
30 | * maps to one attribute of a mesh.
31 | *
32 | * @class Buffer
33 | * @constructor
34 | *
35 | * @param {Number} target The bind target of the buffer to update: ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER
36 | * @param {Object} type Array type to be used in calls to gl.bufferData.
37 | * @param {WebGLContext} gl The WebGL context that the buffer is hosted by.
38 | *
39 | * @return {undefined} undefined
40 | */
41 | function Buffer(target, type, gl) {
42 | this.buffer = null;
43 | this.target = target;
44 | this.type = type;
45 | this.data = [];
46 | this.gl = gl;
47 | }
48 |
49 | /**
50 | * Creates a WebGL buffer if one does not yet exist and binds the buffer to
51 | * to the context. Runs bufferData with appropriate data.
52 | *
53 | * @method
54 | *
55 | * @return {undefined} undefined
56 | */
57 | Buffer.prototype.subData = function subData() {
58 | var gl = this.gl;
59 | var data = [];
60 |
61 | // to prevent against maximum call-stack issue.
62 | for (var i = 0, chunk = 10000; i < this.data.length; i += chunk)
63 | data = Array.prototype.concat.apply(data, this.data.slice(i, i + chunk));
64 |
65 | this.buffer = this.buffer || gl.createBuffer();
66 | gl.bindBuffer(this.target, this.buffer);
67 | gl.bufferData(this.target, new this.type(data), gl.STATIC_DRAW);
68 | };
69 |
70 | module.exports = Buffer;
71 |
--------------------------------------------------------------------------------
/physics/test/forces/Drag.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Drag = require('../../forces/Drag');
28 | var Force = require('../../forces/Force');
29 | var Particle = require('../../bodies/Particle');
30 | var Vec3 = require('../../../math/Vec3');
31 | var test = require('tape');
32 |
33 | function vec3sAreEqual(a,b) {
34 | return Math.abs(a.x - b.x) < 0.001 && Math.abs(a.y - b.y) < 0.001 && Math.abs(a.z - b.z) < 0.001;
35 | }
36 |
37 | test('Drag', function(t) {
38 | var p1 = new Particle({mass:1000});
39 | p1.setVelocity(3,5,8);
40 | var d = new Drag(p1, {strength: 3});
41 |
42 | t.test('should extend Force', function(t) {
43 | t.assert(Drag instanceof Function, 'Drag should be a constructor');
44 |
45 | t.assert(d instanceof Drag && d instanceof Force, 'constructed objects should be instances of Force');
46 |
47 | t.end();
48 | });
49 |
50 | t.test('init prototypal method', function(t) {
51 | t.assert(d.init instanceof Function, '.init should be a function');
52 |
53 | t.assert(d.strength === 3, '.init should set options correctly');
54 |
55 | t.end();
56 | });
57 |
58 | t.test('update prototypal method', function(t) {
59 | t.assert(d.update instanceof Function, '.update should be a function');
60 |
61 | var v = Vec3.clone(p1.velocity);
62 | v.scale(-d.strength);
63 |
64 | d.update();
65 |
66 | t.assert(vec3sAreEqual(p1.force, v), '.update should apply forces correctly');
67 |
68 | t.end();
69 | });
70 |
71 | t.end();
72 | });
73 |
--------------------------------------------------------------------------------
/physics/bodies/Wall.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Particle = require('./Particle');
28 | var Vec3 = require('../../math/Vec3');
29 |
30 | /**
31 | * @enum directions
32 | */
33 | Wall.DOWN = 0;
34 | Wall.UP = 1;
35 | Wall.LEFT = 2;
36 | Wall.RIGHT = 3;
37 | Wall.FORWARD = 4;
38 | Wall.BACKWARD = 5;
39 |
40 | /**
41 | * An axis-aligned boundary. Will not respond to forces or impulses.
42 | *
43 | * @class Wall
44 | * @extends Particle
45 | * @param {Object} options The initial state of the body.
46 | */
47 | function Wall(options) {
48 | Particle.call(this, options);
49 |
50 | var n = this.normal = new Vec3();
51 |
52 | var d = this.direction = options.direction;
53 | switch (d) {
54 | case Wall.DOWN:
55 | n.set(0, 1, 0);
56 | break;
57 | case Wall.UP:
58 | n.set(0, -1, 0);
59 | break;
60 | case Wall.LEFT:
61 | n.set(-1, 0, 0);
62 | break;
63 | case Wall.RIGHT:
64 | n.set(1, 0, 0);
65 | break;
66 | case Wall.FORWARD:
67 | n.set(0, 0, -1);
68 | break;
69 | case Wall.BACKWARD:
70 | n.set(0, 0, 1);
71 | break;
72 | default:
73 | break;
74 | }
75 |
76 | this.invNormal = Vec3.clone(n, new Vec3()).invert();
77 |
78 | this.mass = Infinity;
79 | this.inverseMass = 0;
80 |
81 | this.type = 1 << 3;
82 | }
83 |
84 | Wall.prototype = Object.create(Particle.prototype);
85 | Wall.prototype.constructor = Wall;
86 |
87 | module.exports = Wall;
88 |
--------------------------------------------------------------------------------
/webgl-renderables/test/MockDispatch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | function MockDispatch() {}
28 |
29 | MockDispatch.prototype.addRenderable = function addRenderable() {};
30 |
31 | MockDispatch.prototype.addComponent = function addComponent() {};
32 |
33 | MockDispatch.prototype.getLocation = function getLocation() {
34 | return 'body/0/1';
35 | };
36 |
37 | MockDispatch.prototype.getContext = function getContext() {
38 | return {
39 | _origin: [50, 50, 50],
40 | _opacity: { value: 1 },
41 | _size: {
42 | getTopDownSize: function() {
43 | return [100, 100, 100];
44 | }
45 | },
46 | _transform: {
47 | _matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
48 | }
49 | };
50 | };
51 |
52 | MockDispatch.prototype.sendDrawCommand = function sendDrawCommand() {
53 | return this;
54 | };
55 |
56 | MockDispatch.prototype.dirtyRenderable = function dirtyRenderable() {};
57 |
58 | MockDispatch.prototype.dirtyComponent = function dirtyComponent() {};
59 |
60 | MockDispatch.prototype.onTransformChange = function onTransformChange() {};
61 |
62 | MockDispatch.prototype.onSizeChange = function onSizeChange() {};
63 |
64 | MockDispatch.prototype.onOpacityChange = function onOpacityChange() {};
65 |
66 | MockDispatch.prototype.onOriginChange = function onOriginChange() {};
67 |
68 | MockDispatch.prototype.requestUpdate = function() {};
69 | MockDispatch.prototype.getTransform = function() {
70 | return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
71 | };
72 |
73 | module.exports = MockDispatch;
74 |
--------------------------------------------------------------------------------
/webgl-renderers/test/Buffer.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 | var test = require('tape');
27 | var Buffer = require('../Buffer');
28 | var TestingContext = require('./helpers/ContextWebGL');
29 |
30 | test('Buffer', function(t) {
31 | t.test('constructor', function(t) {
32 | var testingContext = new TestingContext();
33 |
34 | var buffer = new Buffer(
35 | testingContext.ELEMENT_ARRAY_BUFFER,
36 | Uint16Array,
37 | testingContext
38 | );
39 |
40 | t.equals(buffer.target, testingContext.ELEMENT_ARRAY_BUFFER, 'should use input target');
41 | t.equals(buffer.type, Uint16Array, 'should use input type');
42 | t.equals(buffer.buffer, null, 'should not create a buffer object on instantiation');
43 |
44 | t.end();
45 | });
46 |
47 | t.test('subData', function(t) {
48 | var testingContext = new TestingContext();
49 | var buffer = new Buffer(
50 | testingContext.ELEMENT_ARRAY_BUFFER,
51 | Uint16Array,
52 | testingContext
53 | );
54 |
55 | t.ok(buffer.subData instanceof Function, 'should have an subData method');
56 |
57 | buffer.subData();
58 | t.ok(testingContext.createBuffer.callCount === 1, 'should call createBuffer if no buffer currently exists');
59 | t.ok(testingContext.bindBuffer.callCount === 1, 'should call bindBuffer on the context');
60 |
61 | buffer.subData();
62 | t.ok(testingContext.createBuffer.callCount === 1, 'should not call createBuffer if buffer currently exists');
63 |
64 | t.end();
65 | });
66 |
67 | t.end();
68 | });
69 |
--------------------------------------------------------------------------------
/physics/test/forces/RotationalDrag.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var RotationalDrag = require('../../forces/RotationalDrag');
28 | var Force = require('../../forces/Force');
29 | var Box = require('../../bodies/Box');
30 | var Vec3 = require('../../../math/Vec3');
31 | var test = require('tape');
32 |
33 | function vec3sAreEqual(a,b) {
34 | return Math.abs(a.x - b.x) < 0.001 && Math.abs(a.y - b.y) < 0.001 && Math.abs(a.z - b.z) < 0.001;
35 | }
36 |
37 | test('RotationalDrag', function(t) {
38 | var p1 = new Box({mass:1000, size: [10,20,30]});
39 | p1.setAngularVelocity(3,5,8);
40 | var d = new RotationalDrag(p1, {strength: 3});
41 |
42 | t.test('should extend Force', function(t) {
43 | t.assert(RotationalDrag instanceof Function, 'RotationalDrag should be a constructor');
44 |
45 | t.assert(d instanceof RotationalDrag && d instanceof Force, 'constructed objects should be instances of Force');
46 |
47 | t.end();
48 | });
49 |
50 | t.test('init prototypal method', function(t) {
51 | t.assert(d.init instanceof Function, '.init should be a function');
52 |
53 | t.assert(d.strength === 3, '.init should set options correctly');
54 |
55 | t.end();
56 | });
57 |
58 | t.test('update prototypal method', function(t) {
59 | t.assert(d.update instanceof Function, '.update should be a function');
60 |
61 | var v = Vec3.clone(p1.angularVelocity);
62 | v.scale(-d.strength);
63 |
64 | d.update();
65 |
66 | t.assert(vec3sAreEqual(p1.torque, v), '.update should apply forces correctly');
67 |
68 | t.end();
69 | });
70 |
71 | t.end();
72 | });
73 |
--------------------------------------------------------------------------------
/renderers/test/TestingWindow.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | function ClassList(element) {
28 | this._classes = [];
29 | this._element = element;
30 | }
31 |
32 | ClassList.prototype.add = function add(className) {
33 | this._classes.push(className);
34 |
35 | this._element.className += (' ' + className);
36 | };
37 |
38 | function DOMElement(tagName) {
39 | this.style = {};
40 | this.tagName = tagName;
41 | this.className = '';
42 | this.id = null;
43 | this._children = [];
44 | this.classList = new ClassList(this);
45 | }
46 |
47 | DOMElement.prototype.appendChild = function(element) {
48 | return this._children.push(element);
49 | };
50 |
51 | function Document() {
52 | this.body = new DOMElement('body');
53 | }
54 |
55 | Document.prototype.createElement = function(tagName) {
56 | return new DOMElement(tagName);
57 | };
58 |
59 | Document.prototype.querySelector = function(selector) {
60 | var element;
61 | var target;
62 | var result;
63 |
64 |
65 | switch (selector[0]) {
66 | case '#': target = 'id'; result = selector.slice(1); break;
67 | case '.': target = 'class'; result = selector.slice(1); break;
68 | default: target = 'tagName'; result = selector; break;
69 | }
70 |
71 | _traverse(this.body, function(node) {
72 | if (node[target] === result) element = node;
73 | });
74 |
75 | return element;
76 | };
77 |
78 | function _traverse(node, cb) {
79 | var i = node._children.length;
80 |
81 | cb(node);
82 |
83 | while (i--) _traverse(node._children[i], cb);
84 | }
85 |
86 | module.exports = {
87 | document: new Document(),
88 | addEventListener: function() {
89 | }
90 | };
91 |
--------------------------------------------------------------------------------
/transitions/perf/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Transitionable = require('../Transitionable');
28 |
29 | var centerX = window.innerWidth / 2;
30 | var centerY = window.innerHeight / 2;
31 | var radius = Math.sqrt(centerX * centerX + centerY * centerY);
32 | var duration = 750;
33 | var count = 3000;
34 |
35 | function Dot(container) {
36 | this.el = document.createElement('div');
37 | container.appendChild(this.el);
38 | this.el.style.background = 'red';
39 | this.el.style.width = '1px';
40 | this.el.style.height = '1px';
41 | this.el.style.position = 'absolute';
42 | this.transitionable = new Transitionable();
43 | var _this = this;
44 | this._boundStart = function() {
45 | _this.start();
46 | };
47 | this.start();
48 | }
49 |
50 | Dot.prototype.start = function start() {
51 | var angle = Math.random() * Math.PI * 2;
52 | this.transitionable.from([centerX, centerY]).delay(Math.random() * duration).to([
53 | Math.cos(angle) * radius + centerX,
54 | Math.sin(angle) * radius + centerY
55 | ], "inCirc", duration, this._boundStart);
56 | };
57 |
58 | Dot.prototype.update = function update() {
59 | var state = this.transitionable.get();
60 | this.el.style.left = Math.floor(state[0]) + 'px';
61 | this.el.style.top = Math.floor(state[1]) + 'px';
62 | };
63 |
64 | var dots = [];
65 | var container = document.createElement('div');
66 | document.body.appendChild(container);
67 | for (var i = 0; i < count; i++) {
68 | dots.push(new Dot(container));
69 | }
70 |
71 | requestAnimationFrame(function loop() {
72 | for (var i = 0; i < dots.length; i++) {
73 | dots[i].update();
74 | }
75 | requestAnimationFrame(loop);
76 | });
77 |
--------------------------------------------------------------------------------
/physics/constraints/Constraint.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var _ID = 0;
28 | /**
29 | * Base Constraint class to be used in the Physics
30 | * Subclass this class to implement a constraint
31 | *
32 | * @virtual
33 | * @class Constraint
34 | * @param {Object} options The options hash.
35 | */
36 | function Constraint(options) {
37 | options = options || {};
38 | this.setOptions(options);
39 |
40 | this._ID = _ID++;
41 | }
42 |
43 | /**
44 | * Decorates the Constraint with the options object.
45 | *
46 | * @method
47 | * @param {Object} options The options hash.
48 | * @return {undefined} undefined
49 | */
50 | Constraint.prototype.setOptions = function setOptions(options) {
51 | for (var key in options) this[key] = options[key];
52 | this.init(options);
53 | };
54 |
55 | /**
56 | * Method invoked upon instantiation and the setting of options.
57 | *
58 | * @method
59 | * @param {Object} options The options hash.
60 | * @return {undefined} undefined
61 | */
62 | Constraint.prototype.init = function init(options) {};
63 |
64 | /**
65 | * Detect violations of the constraint. Warm start the constraint, if possible.
66 | *
67 | * @method
68 | * @param {Number} time The current time in the physics engine.
69 | * @param {Number} dt The physics engine frame delta.
70 | * @return {undefined} undefined
71 | */
72 | Constraint.prototype.update = function update(time, dt) {};
73 |
74 | /**
75 | * Apply impulses to resolve the constraint.
76 | *
77 | * @method
78 | * @param {Number} time The current time in the physics engine.
79 | * @param {Number} dt The physics engine frame delta.
80 | * @return {undefined} undefined
81 | */
82 | Constraint.prototype.resolve = function resolve(time, dt) {};
83 |
84 | module.exports = Constraint;
85 |
--------------------------------------------------------------------------------
/dom-renderers/events/InputEvent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var UIEvent = require('./UIEvent');
28 |
29 | /**
30 | * See [Input Events](http://w3c.github.io/editing-explainer/input-events.html#idl-def-InputEvent).
31 | *
32 | * @class InputEvent
33 | * @augments UIEvent
34 | *
35 | * @param {Event} ev The native DOM event.
36 | */
37 | function InputEvent(ev) {
38 | // [Constructor(DOMString typeArg, optional InputEventInit inputEventInitDict)]
39 | // interface InputEvent : UIEvent {
40 | // readonly attribute DOMString inputType;
41 | // readonly attribute DOMString data;
42 | // readonly attribute boolean isComposing;
43 | // readonly attribute Range targetRange;
44 | // };
45 |
46 | UIEvent.call(this, ev);
47 |
48 | /**
49 | * @name InputEvent#inputType
50 | * @type String
51 | */
52 | this.inputType = ev.inputType;
53 |
54 | /**
55 | * @name InputEvent#data
56 | * @type String
57 | */
58 | this.data = ev.data;
59 |
60 | /**
61 | * @name InputEvent#isComposing
62 | * @type Boolean
63 | */
64 | this.isComposing = ev.isComposing;
65 |
66 | /**
67 | * **Limited browser support**.
68 | *
69 | * @name InputEvent#targetRange
70 | * @type Boolean
71 | */
72 | this.targetRange = ev.targetRange;
73 | }
74 |
75 | InputEvent.prototype = Object.create(UIEvent.prototype);
76 | InputEvent.prototype.constructor = InputEvent;
77 |
78 | /**
79 | * Return the name of the event type
80 | *
81 | * @method
82 | *
83 | * @return {String} Name of the event type
84 | */
85 | InputEvent.prototype.toString = function toString () {
86 | return 'InputEvent';
87 | };
88 |
89 | module.exports = InputEvent;
90 |
--------------------------------------------------------------------------------
/webgl-shaders/chunks/getNormalMatrix.glsl:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Calculates transpose inverse matrix from transform
27 | *
28 | * @method random
29 | * @private
30 | *
31 | *
32 | */
33 |
34 |
35 | mat3 getNormalMatrix(in mat4 t) {
36 | mat3 matNorm;
37 | mat4 a = t;
38 |
39 | float a00 = a[0][0], a01 = a[0][1], a02 = a[0][2], a03 = a[0][3],
40 | a10 = a[1][0], a11 = a[1][1], a12 = a[1][2], a13 = a[1][3],
41 | a20 = a[2][0], a21 = a[2][1], a22 = a[2][2], a23 = a[2][3],
42 | a30 = a[3][0], a31 = a[3][1], a32 = a[3][2], a33 = a[3][3],
43 | b00 = a00 * a11 - a01 * a10,
44 | b01 = a00 * a12 - a02 * a10,
45 | b02 = a00 * a13 - a03 * a10,
46 | b03 = a01 * a12 - a02 * a11,
47 | b04 = a01 * a13 - a03 * a11,
48 | b05 = a02 * a13 - a03 * a12,
49 | b06 = a20 * a31 - a21 * a30,
50 | b07 = a20 * a32 - a22 * a30,
51 | b08 = a20 * a33 - a23 * a30,
52 | b09 = a21 * a32 - a22 * a31,
53 | b10 = a21 * a33 - a23 * a31,
54 | b11 = a22 * a33 - a23 * a32,
55 |
56 | det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
57 | det = 1.0 / det;
58 |
59 | matNorm[0][0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
60 | matNorm[0][1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
61 | matNorm[0][2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
62 |
63 | matNorm[1][0] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
64 | matNorm[1][1] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
65 | matNorm[1][2] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
66 |
67 | matNorm[2][0] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
68 | matNorm[2][1] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
69 | matNorm[2][2] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
70 |
71 | return matNorm;
72 | }
73 |
74 | #pragma glslify: export(getNormalMatrix)
75 |
--------------------------------------------------------------------------------
/physics/test/forces/Gravity3D.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Gravity3D = require('../../forces/Gravity3D');
28 | var Force = require('../../forces/Force');
29 | var Particle = require('../../bodies/Particle');
30 | var Vec3 = require('../../../math/Vec3');
31 | var test = require('tape');
32 |
33 | function vec3sAreEqual(a,b) {
34 | return Math.abs(a.x - b.x) < 0.001 && Math.abs(a.y - b.y) < 0.001 && Math.abs(a.z - b.z) < 0.001;
35 | }
36 |
37 | test('Gravity3D', function(t) {
38 | var p1 = new Particle({mass:1000});
39 | var p2 = new Particle({mass: 22});
40 | p2.setPosition(10,20,30);
41 | var g = new Gravity3D(p1, p2, {strength: 123});
42 |
43 | t.test('should extend Force', function(t) {
44 | t.assert(Gravity3D instanceof Function, 'Gravity3D should be a constructor');
45 |
46 | t.assert(g instanceof Gravity3D && g instanceof Force, 'constructed objects should be instances of Force');
47 |
48 | t.end();
49 | });
50 |
51 | t.test('init prototypal method', function(t) {
52 | t.assert(g.init instanceof Function, '.init should be a function');
53 |
54 | t.assert(g.strength === 123, '.init should set .strength correctly');
55 |
56 | t.end();
57 | });
58 |
59 | t.test('update prototypal method', function(t) {
60 | t.assert(g.update instanceof Function, '.update should be a function');
61 |
62 | g.update();
63 |
64 | var e = Vec3.subtract(p1.position, p2.position, new Vec3());
65 | e.normalize();
66 | var d = Math.sqrt(10*10+20*20+30*30);
67 | e.scale(123*1000*22/(d*d));
68 |
69 | t.assert(vec3sAreEqual(p2.force, e) && vec3sAreEqual(p1.force, e.invert()), '.update should apply forces correctly');
70 |
71 | t.end();
72 | });
73 |
74 | t.end();
75 | });
76 |
--------------------------------------------------------------------------------
/webgl-geometries/primitives/Icosahedron.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Geometry = require('../Geometry');
28 | var GeometryHelper = require('../GeometryHelper');
29 |
30 | /**
31 | * This function returns a new static geometry, which is passed
32 | * custom buffer data.
33 | *
34 | * @class Icosahedron
35 | * @constructor
36 | *
37 | * @param {Object} options Parameters that alter the
38 | * vertex buffers of the generated geometry.
39 | *
40 | * @return {Object} constructed geometry
41 | */
42 | function Icosahedron( options )
43 | {
44 | options = options || {};
45 | var t = ( 1 + Math.sqrt( 5 ) ) / 2;
46 |
47 | var vertices = [
48 | - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0,
49 | 0, - 1, -t, 0, 1, -t, 0, - 1, t, 0, 1, t,
50 | t, 0, 1, t, 0, -1, - t, 0, 1, - t, 0, -1
51 | ];
52 | var indices = [
53 | 0, 5, 11, 0, 1, 5, 0, 7, 1, 0, 10, 7, 0, 11, 10,
54 | 1, 9, 5, 5, 4, 11, 11, 2, 10, 10, 6, 7, 7, 8, 1,
55 | 3, 4, 9, 3, 2, 4, 3, 6, 2, 3, 8, 6, 3, 9, 8,
56 | 4, 5, 9, 2, 11, 4, 6, 10, 2, 8, 7, 6, 9, 1, 8
57 | ];
58 |
59 | GeometryHelper.getUniqueFaces(vertices, indices);
60 |
61 | var normals = GeometryHelper.computeNormals(vertices, indices);
62 | var textureCoords = GeometryHelper.getSpheroidUV(vertices);
63 |
64 | vertices = GeometryHelper.normalizeAll(vertices);
65 |
66 | options.buffers = [
67 | { name: 'a_pos', data: vertices },
68 | { name: 'a_texCoord', data: textureCoords, size: 2 },
69 | { name: 'a_normals', data: normals },
70 | { name: 'indices', data: indices, size: 1 }
71 | ];
72 |
73 | return new Geometry(options);
74 | }
75 |
76 | module.exports = Icosahedron;
77 |
--------------------------------------------------------------------------------
/components/Rotation.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Position = require('./Position');
28 |
29 | /**
30 | * Rotation is a component that allows the tweening of a Node's rotation. Rotation
31 | * happens about a Node's origin which is by default [0, 0, .5].
32 | *
33 | * @class Rotation
34 | * @augments Position
35 | *
36 | * @param {Node} node Node that the Rotation component will be attached to
37 | */
38 | function Rotation(node) {
39 | Position.call(this, node);
40 |
41 | var initial = node.getRotation();
42 |
43 | var x = initial[0];
44 | var y = initial[1];
45 | var z = initial[2];
46 | var w = initial[3];
47 |
48 | var xx = x * x;
49 | var yy = y * y;
50 | var zz = z * z;
51 |
52 | var ty = 2 * (x * z + y * w);
53 | ty = ty < -1 ? -1 : ty > 1 ? 1 : ty;
54 |
55 | var rx = Math.atan2(2 * (x * w - y * z), 1 - 2 * (xx + yy));
56 | var ry = Math.asin(ty);
57 | var rz = Math.atan2(2 * (z * w - x * y), 1 - 2 * (yy + zz));
58 |
59 | this._x.set(rx);
60 | this._y.set(ry);
61 | this._z.set(rz);
62 | }
63 |
64 | /**
65 | * Return the name of the Rotation component
66 | *
67 | * @method
68 | *
69 | * @return {String} Name of the component
70 | */
71 | Rotation.prototype.toString = function toString() {
72 | return 'Rotation';
73 | };
74 |
75 | Rotation.prototype = Object.create(Position.prototype);
76 | Rotation.prototype.constructor = Rotation;
77 |
78 | /**
79 | * When the node this component is attached to updates, update the value
80 | * of the Node's rotation
81 | *
82 | * @method
83 | *
84 | * @return {undefined} undefined
85 | */
86 | Rotation.prototype.update = function update() {
87 | this._node.setRotation(this._x.get(), this._y.get(), this._z.get());
88 | this._checkUpdate();
89 | };
90 |
91 | Rotation.prototype.onUpdate = Rotation.prototype.update;
92 |
93 | module.exports = Rotation;
94 |
--------------------------------------------------------------------------------
/polyfills/animationFrame.js:
--------------------------------------------------------------------------------
1 | // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2 | // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
3 | // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
4 | // MIT license
5 |
6 | 'use strict';
7 |
8 | var lastTime = 0;
9 | var vendors = ['ms', 'moz', 'webkit', 'o'];
10 |
11 | var rAF, cAF;
12 |
13 | if (typeof window === 'object') {
14 | rAF = window.requestAnimationFrame;
15 | cAF = window.cancelAnimationFrame || window.cancelRequestAnimationFrame;
16 | for (var x = 0; x < vendors.length && !rAF; ++x) {
17 | rAF = window[vendors[x] + 'RequestAnimationFrame'];
18 | cAF = window[vendors[x] + 'CancelRequestAnimationFrame'] ||
19 | window[vendors[x] + 'CancelAnimationFrame'];
20 | }
21 |
22 | if (rAF && !cAF) {
23 | // cAF not supported.
24 | // Fall back to setInterval for now (very rare).
25 | rAF = null;
26 | }
27 | }
28 |
29 | if (!rAF) {
30 | var now = Date.now ? Date.now : function () {
31 | return new Date().getTime();
32 | };
33 |
34 | rAF = function(callback) {
35 | var currTime = now();
36 | var timeToCall = Math.max(0, 16 - (currTime - lastTime));
37 | var id = setTimeout(function () {
38 | callback(currTime + timeToCall);
39 | }, timeToCall);
40 | lastTime = currTime + timeToCall;
41 | return id;
42 | };
43 |
44 | cAF = function (id) {
45 | clearTimeout(id);
46 | };
47 | }
48 |
49 | var animationFrame = {
50 | /**
51 | * Cross browser version of [requestAnimationFrame]{@link https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame}.
52 | *
53 | * Used by Engine in order to establish a render loop.
54 | *
55 | * If no (vendor prefixed version of) `requestAnimationFrame` is available,
56 | * `setTimeout` will be used in order to emulate a render loop running at
57 | * approximately 60 frames per second.
58 | *
59 | * @method requestAnimationFrame
60 | *
61 | * @param {Function} callback function to be invoked on the next frame.
62 | * @return {Number} requestId to be used to cancel the request using
63 | * {@link cancelAnimationFrame}.
64 | */
65 | requestAnimationFrame: rAF,
66 |
67 | /**
68 | * Cross browser version of [cancelAnimationFrame]{@link https://developer.mozilla.org/en-US/docs/Web/API/window/cancelAnimationFrame}.
69 | *
70 | * Cancels a previously using [requestAnimationFrame]{@link animationFrame#requestAnimationFrame}
71 | * scheduled request.
72 | *
73 | * Used for immediately stopping the render loop within the Engine.
74 | *
75 | * @method cancelAnimationFrame
76 | *
77 | * @param {Number} requestId of the scheduled callback function
78 | * returned by [requestAnimationFrame]{@link animationFrame#requestAnimationFrame}.
79 | */
80 | cancelAnimationFrame: cAF
81 | };
82 |
83 | module.exports = animationFrame;
84 |
--------------------------------------------------------------------------------
/webgl-geometries/primitives/Box.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Geometry = require('../Geometry');
28 |
29 | function pickOctant(i) {
30 | return [(i & 1) * 2 - 1, (i & 2) - 1, (i & 4) / 2 - 1];
31 | }
32 |
33 | var boxData = [
34 | [0, 4, 2, 6, -1, 0, 0],
35 | [1, 3, 5, 7, +1, 0, 0],
36 | [0, 1, 4, 5, 0, -1, 0],
37 | [2, 6, 3, 7, 0, +1, 0],
38 | [0, 2, 1, 3, 0, 0, -1],
39 | [4, 5, 6, 7, 0, 0, +1]
40 | ];
41 |
42 | /**
43 | * This function returns a new static geometry, which is passed
44 | * custom buffer data.
45 | *
46 | * @class BoxGeometry
47 | * @constructor
48 | *
49 | * @param {Object} options Parameters that alter the
50 | * vertex buffers of the generated geometry.
51 | *
52 | * @return {Object} constructed geometry
53 | */
54 | function BoxGeometry(options) {
55 | options = options || {};
56 |
57 | var vertices = [];
58 | var textureCoords = [];
59 | var normals = [];
60 | var indices = [];
61 |
62 | var data;
63 | var d;
64 | var v;
65 | var i;
66 | var j;
67 |
68 | for (i = 0; i < boxData.length; i++) {
69 | data = boxData[i];
70 | v = i * 4;
71 | for (j = 0; j < 4; j++) {
72 | d = data[j];
73 | var octant = pickOctant(d);
74 | vertices.push(octant[0], octant[1], octant[2]);
75 | textureCoords.push(j & 1, (j & 2) / 2);
76 | normals.push(data[4], data[5], data[6]);
77 | }
78 | indices.push(v, v + 1, v + 2);
79 | indices.push(v + 2, v + 1, v + 3);
80 |
81 | }
82 |
83 | options.buffers = [
84 | { name: 'a_pos', data: vertices },
85 | { name: 'a_texCoord', data: textureCoords, size: 2 },
86 | { name: 'a_normals', data: normals },
87 | { name: 'indices', data: indices, size: 1 }
88 | ];
89 |
90 | return new Geometry(options);
91 | }
92 |
93 | module.exports = BoxGeometry;
94 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Active involvement from the community is essential to making the Famous Engine the most capable and performant JavaScript rendering engine. You can help by reporting bugs, fixing bugs, adding features, and providing feedback.
4 |
5 | ## Reporting bugs and other issues
6 |
7 | Famous is a platform that is always testing the limits of where browsers can go. As a result, it's likely that you may encounter bugs or other issues while developing with it. If you think you've encountered a bug, do the following:
8 |
9 | 1. Make sure you are working with the latest version of the Famous `develop` branch.
10 | 2. Browse through the [issues][1] to check if anyone else has already reported the issue you're seeing. If someone has, feel free to add more information to that issue.
11 | 3. If no one has yet submitted the issue you are encountering, be sure to include as much information as possible, including errors, warnings, screenshots, or videos that help us reproduce it.
12 |
13 | ## Contributing code
14 |
15 | The Famous platform is made possible by contributors like you. We're thrilled to get help from the greater community --- but before you start, **become acquainted with our workflow**. Following these guidelines below will make collaboration much smoother and increase the chances that we will accept your pull request.
16 |
17 | ### Development process
18 |
19 | Our development process is very similar to the approach described in the article [_A Successful Git Branching Model_][2]. Here's an overview:
20 |
21 | * Our `develop` branch is the main development branch.
22 | * All commits intended for `develop` should be submitted via pull request.
23 | * Only maintainers can accept pull requests from forks.
24 | * Please squash your commits into a single commit before making a pull request.
25 |
26 | ### Getting started
27 |
28 | 1. Make sure you have a [GitHub account][4].
29 | 2. [Fork famous][5].
30 | 3. Keep your fork up to date.
31 | 4. Make sure you have a [Contributor License Agreement][6] on file.
32 |
33 | ### Contributor License Agreement
34 |
35 | Before we can accept any contributions to Famous, we first require that all individuals or companies agree to our [Contributor License Agreement (CLA)][6].
36 |
37 | The e-mail address used in the pull request will be used to check if a CLA has already been filed, so be sure to list all email addresses that you might use to submit your pull requests when filling it out.
38 |
39 | ### Testing
40 |
41 | All pull requests must pass our tests before they can be merged. Any new functionality should have corresponding tests to ensure they are working properly.
42 |
43 | ### Bug fixes
44 |
45 | If you'd like to contribute a fix for a bug, first read up on [how to report a bug][7]. By filing the issue first, we may be able to provide you with some insight that guides you in the right direction.
46 |
47 | [1]: https://github.com/Famous/engine/issues
48 | [2]: http://nvie.com/posts/a-successful-git-branching-model/
49 | [3]: https://github.com/Famous/engine
50 | [4]: https://github.com/signup/free
51 | [5]: https://github.com/Famous/engine/fork
52 | [6]: http://famous.org/cla
53 | [7]: #reporting-bugs-and-other-issues
54 |
--------------------------------------------------------------------------------
/webgl-materials/TextureRegistry.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | /*
28 | * A singleton object that holds texture instances in a registry which
29 | * can be accessed by key. Allows for texture sharing and easy referencing.
30 | *
31 | * @static
32 | * @class TextureRegistry
33 | */
34 | var TextureRegistry = {
35 | registry: {},
36 | textureIds: 1
37 | };
38 |
39 | /*
40 | * Registers a new Texture object with a unique id and input parameters to be
41 | * handled by the WebGLRenderer. If no accessor is input the texture will be
42 | * created but not store in the registry.
43 | *
44 | * @method register
45 | *
46 | * @param {String} accessor Key used to later access the texture object.
47 | * @param {Object | Array | String} data Data to be used in the WebGLRenderer to
48 | * generate texture data.
49 | * @param {Object} options Optional parameters to affect the rendering of the
50 | * WebGL texture.
51 | *
52 | * @return {Object} Newly generated texture object.
53 | */
54 | TextureRegistry.register = function register(accessor, data, options) {
55 | if (accessor) {
56 | this.registry[accessor] = { id: this.textureIds++, __isATexture__: true, data: data, options: options };
57 | return this.registry[accessor];
58 | }
59 | else {
60 | return { id: this.textureIds++, data: data, __isATexture__: true, options: options };
61 | }
62 | };
63 |
64 | /*
65 | * Retreives the texture object from registry. Throws if no texture is
66 | * found at given key.
67 | *
68 | * @method get
69 | *
70 | * @param {String} accessor Key of a desired texture in the registry.
71 | *
72 | * @return {Object} Desired texture object.
73 | */
74 | TextureRegistry.get = function get(accessor) {
75 | if (!this.registry[accessor]) {
76 | throw 'Texture "' + accessor + '" not found!';
77 | }
78 | else {
79 | return this.registry[accessor];
80 | }
81 | };
82 |
83 | module.exports = TextureRegistry;
84 |
--------------------------------------------------------------------------------
/webgl-geometries/primitives/Sphere.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var Geometry = require('../Geometry');
28 | var GeometryHelper = require('../GeometryHelper');
29 |
30 | /**
31 | * This function returns a new static geometry, which is passed
32 | * custom buffer data.
33 | *
34 | * @class ParametricSphere
35 | * @constructor
36 | *
37 | * @param {Object} options Parameters that alter the
38 | * vertex buffers of the generated geometry.
39 | *
40 | * @return {Object} constructed geometry
41 | */
42 | function ParametricSphere (options) {
43 | options = options || {};
44 | var detail = options.detail || 10;
45 | var detailX = options.detailX || detail;
46 | var detailY = options.detailY || detail;
47 |
48 | var buffers = GeometryHelper.generateParametric(
49 | detailX,
50 | detailY,
51 | ParametricSphere.generator,
52 | true
53 | );
54 |
55 | options.buffers = [
56 | { name: 'a_pos', data: buffers.vertices },
57 | { name: 'a_texCoord', data: GeometryHelper.getSpheroidUV(buffers.vertices), size: 2 },
58 | { name: 'a_normals', data: GeometryHelper.getSpheroidNormals(buffers.vertices) },
59 | { name: 'indices', data: buffers.indices, size: 1 }
60 | ];
61 |
62 | return new Geometry(options);
63 | }
64 |
65 | /**
66 | * Function used in iterative construction of parametric primitive.
67 | *
68 | * @static
69 | * @method
70 | * @param {Number} u Longitudal progress from 0 to PI.
71 | * @param {Number} v Latitudal progress from 0 to PI.
72 | * @param {Array} pos X, Y, Z position of vertex at given slice and stack.
73 | *
74 | * @return {undefined} undefined
75 | */
76 | ParametricSphere.generator = function generator(u, v, pos) {
77 | var x = Math.sin(u) * Math.cos(v);
78 | var y = Math.cos(u);
79 | var z = -Math.sin(u) * Math.sin(v);
80 |
81 | pos[0] = x;
82 | pos[1] = y;
83 | pos[2] = z;
84 | };
85 |
86 | module.exports = ParametricSphere;
87 |
--------------------------------------------------------------------------------
/renderers/inject-css.js:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Famous Industries Inc.
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | 'use strict';
26 |
27 | var css = '.famous-dom-renderer {' +
28 | 'width:100%;' +
29 | 'height:100%;' +
30 | 'transform-style:preserve-3d;' +
31 | '-webkit-transform-style:preserve-3d;' +
32 | '}' +
33 |
34 | '.famous-dom-element {' +
35 | '-webkit-transform-origin:0% 0%;' +
36 | 'transform-origin:0% 0%;' +
37 | '-webkit-backface-visibility:visible;' +
38 | 'backface-visibility:visible;' +
39 | '-webkit-transform-style:preserve-3d;' +
40 | 'transform-style:preserve-3d;' +
41 | '-webkit-tap-highlight-color:transparent;' +
42 | 'pointer-events:auto;' +
43 | 'z-index:1;' +
44 | '}' +
45 |
46 | '.famous-dom-element-content,' +
47 | '.famous-dom-element {' +
48 | 'position:absolute;' +
49 | 'box-sizing:border-box;' +
50 | '-moz-box-sizing:border-box;' +
51 | '-webkit-box-sizing:border-box;' +
52 | '}' +
53 |
54 | '.famous-webgl-renderer {' +
55 | '-webkit-transform:translateZ(1000000px);' + /* TODO: Fix when Safari Fixes*/
56 | 'transform:translateZ(1000000px);' +
57 | 'pointer-events:none;' +
58 | 'position:absolute;' +
59 | 'z-index:1;' +
60 | 'top:0;' +
61 | 'width:100%;' +
62 | 'height:100%;' +
63 | '}';
64 |
65 | var INJECTED = typeof document === 'undefined';
66 |
67 | function injectCSS() {
68 | if (INJECTED) return;
69 | INJECTED = true;
70 | if (document.createStyleSheet) {
71 | var sheet = document.createStyleSheet();
72 | sheet.cssText = css;
73 | }
74 | else {
75 | var head = document.getElementsByTagName('head')[0];
76 | var style = document.createElement('style');
77 |
78 | if (style.styleSheet) {
79 | style.styleSheet.cssText = css;
80 | }
81 | else {
82 | style.appendChild(document.createTextNode(css));
83 | }
84 |
85 | (head ? head : document.documentElement).appendChild(style);
86 | }
87 | }
88 |
89 | module.exports = injectCSS;
90 |
--------------------------------------------------------------------------------