code
stringlengths 10
343k
| docstring
stringlengths 36
21.9k
| func_name
stringlengths 1
3.35k
| language
stringclasses 1
value | repo
stringlengths 7
58
| path
stringlengths 4
131
| url
stringlengths 44
195
| license
stringclasses 5
values |
---|---|---|---|---|---|---|---|
FamousEngine.prototype.getContext = function getContext (selector) {
if (!selector) throw new Error('getContext must be called with a selector');
var index = selector.indexOf('/');
selector = index === -1 ? selector : selector.substring(0, index);
return this._scenes[selector];
}; | returns the context of a particular path. The context is looked up by the selector
portion of the path and is listed from the start of the string to the first
'/'.
@method
@param {String} selector the path to look up the context for.
@return {Context | Undefined} the context if found, else undefined. | getContext ( selector ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.getClock = function getClock () {
return this._clock;
}; | Returns the instance of clock used by the FamousEngine.
@method
@return {Clock} FamousEngine's clock | getClock ( ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.message = function message (command) {
this._messages.push(command);
return this;
}; | Enqueues a message to be transfered to the renderers.
@method
@param {Any} command Draw Command
@return {FamousEngine} this | message ( command ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.createScene = function createScene (selector) {
selector = selector || 'body';
if (this._scenes[selector]) this._scenes[selector].dismount();
this._scenes[selector] = new Scene(selector, this);
return this._scenes[selector];
}; | Creates a scene under which a scene graph could be built.
@method
@param {String} selector a dom selector for where the scene should be placed
@return {Scene} a new instance of Scene. | createScene ( selector ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.addScene = function addScene (scene) {
var selector = scene._selector;
var current = this._scenes[selector];
if (current && current !== scene) current.dismount();
if (!scene.isMounted()) scene.mount(scene.getSelector());
this._scenes[selector] = scene;
return this;
}; | Introduce an already instantiated scene to the engine.
@method
@param {Scene} scene the scene to reintroduce to the engine
@return {FamousEngine} this | addScene ( scene ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.removeScene = function removeScene (scene) {
var selector = scene._selector;
var current = this._scenes[selector];
if (current && current === scene) {
if (scene.isMounted()) scene.dismount();
delete this._scenes[selector];
}
return this;
}; | Remove a scene.
@method
@param {Scene} scene the scene to remove from the engine
@return {FamousEngine} this | removeScene ( scene ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.startRenderLoop = function startRenderLoop() {
this._channel.sendMessage(ENGINE_START);
return this;
}; | Starts the engine running in the Main-Thread.
This effects **every** updateable managed by the Engine.
@method
@return {FamousEngine} this | startRenderLoop ( ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.stopRenderLoop = function stopRenderLoop() {
this._channel.sendMessage(ENGINE_STOP);
return this;
}; | Stops the engine running in the Main-Thread.
This effects **every** updateable managed by the Engine.
@method
@return {FamousEngine} this | stopRenderLoop ( ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.startEngine = function startEngine() {
console.warn(
'FamousEngine.startEngine is deprecated! Use ' +
'FamousEngine.startRenderLoop instead!'
);
return this.startRenderLoop();
}; | @method
@deprecated Use {@link FamousEngine#startRenderLoop} instead!
@return {FamousEngine} this | startEngine ( ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
FamousEngine.prototype.stopEngine = function stopEngine() {
console.warn(
'FamousEngine.stopEngine is deprecated! Use ' +
'FamousEngine.stopRenderLoop instead!'
);
return this.stopRenderLoop();
}; | @method
@deprecated Use {@link FamousEngine#stopRenderLoop} instead!
@return {FamousEngine} this | stopEngine ( ) | javascript | Famous/engine | core/FamousEngine.js | https://github.com/Famous/engine/blob/master/core/FamousEngine.js | MIT |
function Node () {
this._requestingUpdate = false;
this._inUpdate = false;
this._mounted = false;
this._shown = true;
this._updater = null;
this._opacity = 1;
this._UIEvents = [];
this._updateQueue = [];
this._nextUpdateQueue = [];
this._freedComponentIndicies = [];
this._components = [];
this._freedChildIndicies = [];
this._children = [];
this._fullChildren = [];
this._parent = null;
this._id = null;
this._transformID = null;
this._sizeID = null;
if (!this.constructor.NO_DEFAULT_COMPONENTS) this._init();
} | Nodes define hierarchy and geometrical transformations. They can be moved
(translated), scaled and rotated.
A Node is either mounted or unmounted. Unmounted nodes are detached from the
scene graph. Unmounted nodes have no parent node, while each mounted node has
exactly one parent. Nodes have an arbitrary number of children, which can be
dynamically added using {@link Node#addChild}.
Each Node has an arbitrary number of `components`. Those components can
send `draw` commands to the renderer or mutate the node itself, in which case
they define behavior in the most explicit way. Components that send `draw`
commands are considered `renderables`. From the node's perspective, there is
no distinction between nodes that send draw commands and nodes that define
behavior.
Because of the fact that Nodes themself are very unopinioted (they don't
"render" to anything), they are often being subclassed in order to add e.g.
components at initialization to them. Because of this flexibility, they might
as well have been called `Entities`.
@example
// create three detached (unmounted) nodes
var parent = new Node();
var child1 = new Node();
var child2 = new Node();
// build an unmounted subtree (parent is still detached)
parent.addChild(child1);
parent.addChild(child2);
// mount parent by adding it to the context
var context = Famous.createContext("body");
context.addChild(parent);
@class Node
@constructor | Node ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._init = function _init () {
this._transformID = this.addComponent(new Transform());
this._sizeID = this.addComponent(new Size());
}; | Protected method. Initializes a node with a default Transform and Size component
@method
@protected
@return {undefined} undefined | _init ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._setParent = function _setParent (parent) {
if (this._parent && this._parent.getChildren().indexOf(this) !== -1) {
this._parent.removeChild(this);
}
this._parent = parent;
}; | Protected method. Sets the parent of this node such that it can be looked up.
@method
@param {Node} parent The node to set as the parent of this
@return {undefined} undefined; | _setParent ( parent ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._setMounted = function _setMounted (mounted, path) {
this._mounted = mounted;
this._id = path ? path : null;
}; | Protected method. Sets the mount state of the node. Should only be called
by the dispatch
@method
@param {Boolean} mounted whether or not the Node is mounted.
@param {String} path The path that the node will be mounted to
@return {undefined} undefined | _setMounted ( mounted , path ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._setShown = function _setShown (shown) {
this._shown = shown;
}; | Protected method, sets whether or not the Node is shown. Should only
be called by the dispatch
@method
@param {Boolean} shown whether or not the node is shown
@return {undefined} undefined | _setShown ( shown ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._setUpdater = function _setUpdater (updater) {
this._updater = updater;
if (this._requestingUpdate) this._updater.requestUpdate(this);
}; | Protected method. Sets the updater of the node.
@method
@param {FamousEngine} updater the Updater of the node.
@return {undefined} undefined | _setUpdater ( updater ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getLocation = function getLocation () {
return this._id;
}; | Determine the node's location in the scene graph hierarchy.
A location of `body/0/1` can be interpreted as the following scene graph
hierarchy (ignoring siblings of ancestors and additional child nodes):
`Context:body` -> `Node:0` -> `Node:1`, where `Node:1` is the node the
`getLocation` method has been invoked on.
@method getLocation
@return {String} location (path), e.g. `body/0/1` | getLocation ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.emit = function emit (event, payload) {
Dispatch.dispatch(this.getLocation(), event, payload);
return this;
}; | Dispatches the event using the Dispatch. All descendent nodes will
receive the dispatched event.
@method emit
@param {String} event Event type.
@param {Object} payload Event object to be dispatched.
@return {Node} this | emit ( event , payload ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getChildren = function getChildren () {
return this._fullChildren;
}; | Retrieves all children of the current node.
@method getChildren
@return {Array.<Node>} An array of children. | getChildren ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getRawChildren = function getRawChildren() {
return this._children;
}; | Method used internally to retrieve the children of a node. Each index in the
returned array represents a path fragment.
@method getRawChildren
@private
@return {Array} An array of children. Might contain `null` elements. | getRawChildren ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getParent = function getParent () {
return this._parent;
}; | Retrieves the parent of the current node. Unmounted nodes do not have a
parent node.
@method getParent
@return {Node} Parent node. | getParent ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.requestUpdate = function requestUpdate (requester) {
if (this._inUpdate || !this.isMounted())
return this.requestUpdateOnNextTick(requester);
if (this._updateQueue.indexOf(requester) === -1) {
this._updateQueue.push(requester);
if (!this._requestingUpdate) this._requestUpdate();
}
return this;
}; | Schedules the {@link Node#update} function of the node to be invoked on the
next frame (if no update during this frame has been scheduled already).
If the node is currently being updated (which means one of the requesters
invoked requestsUpdate while being updated itself), an update will be
scheduled on the next frame.
@method requestUpdate
@param {Object} requester If the requester has an `onUpdate` method, it
will be invoked during the next update phase of
the node.
@return {Node} this | requestUpdate ( requester ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.requestUpdateOnNextTick = function requestUpdateOnNextTick (requester) {
if (this._nextUpdateQueue.indexOf(requester) === -1)
this._nextUpdateQueue.push(requester);
return this;
}; | Schedules an update on the next tick. Similarily to
{@link Node#requestUpdate}, `requestUpdateOnNextTick` schedules the node's
`onUpdate` function to be invoked on the frame after the next invocation on
the node's onUpdate function.
@method requestUpdateOnNextTick
@param {Object} requester If the requester has an `onUpdate` method, it
will be invoked during the next update phase of
the node.
@return {Node} this | requestUpdateOnNextTick ( requester ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.isMounted = function isMounted () {
return this._mounted;
}; | Checks if the node is mounted. Unmounted nodes are detached from the scene
graph.
@method isMounted
@return {Boolean} Boolean indicating whether the node is mounted or not. | isMounted ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.isRendered = function isRendered () {
return this._mounted && this._shown;
}; | Checks if the node is being rendered. A node is being rendererd when it is
mounted to a parent node **and** shown.
@method isRendered
@return {Boolean} Boolean indicating whether the node is rendered or not. | isRendered ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.isShown = function isShown () {
return this._shown;
}; | Checks if the node is visible ("shown").
@method isShown
@return {Boolean} Boolean indicating whether the node is visible
("shown") or not. | isShown ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getOpacity = function getOpacity () {
return this._opacity;
}; | Determines the node's relative opacity.
The opacity needs to be within [0, 1], where 0 indicates a completely
transparent, therefore invisible node, whereas an opacity of 1 means the
node is completely solid.
@method getOpacity
@return {Number} Relative opacity of the node. | getOpacity ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getMountPoint = function getMountPoint () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getMountPoint();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getMountPoint();
else throw new Error('This node does not have access to a transform component');
}; | Determines the node's previously set mount point.
@method getMountPoint
@return {Float32Array} An array representing the mount point. | getMountPoint ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getAlign = function getAlign () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getAlign();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getAlign();
else throw new Error('This node does not have access to a transform component');
}; | Determines the node's previously set align.
@method getAlign
@return {Float32Array} An array representing the align. | getAlign ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getOrigin = function getOrigin () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getOrigin();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getOrigin();
else throw new Error('This node does not have access to a transform component');
}; | Determines the node's previously set origin.
@method getOrigin
@return {Float32Array} An array representing the origin. | getOrigin ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getPosition = function getPosition () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getPosition();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getPosition();
else throw new Error('This node does not have access to a transform component');
}; | Determines the node's previously set position.
@method getPosition
@return {Float32Array} An array representing the position. | getPosition ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getRotation = function getRotation () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getRotation();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getRotation();
else throw new Error('This node does not have access to a transform component');
}; | Returns the node's current rotation
@method getRotation
@return {Float32Array} an array of four values, showing the rotation as a quaternion | getRotation ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getScale = function getScale () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._transformID).getScale();
else if (this.isMounted())
return TransformSystem.get(this.getLocation()).getScale();
else throw new Error('This node does not have access to a transform component');
}; | Returns the scale of the node
@method
@return {Float32Array} an array showing the current scale vector | getScale ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getSizeMode = function getSizeMode () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).getSizeMode();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).getSizeMode();
else throw new Error('This node does not have access to a size component');
}; | Returns the current size mode of the node
@method
@return {Float32Array} an array of numbers showing the current size mode | getSizeMode ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getProportionalSize = function getProportionalSize () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).getProportional();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).getProportional();
else throw new Error('This node does not have access to a size component');
}; | Returns the current proportional size
@method
@return {Float32Array} a vector 3 showing the current proportional size | getProportionalSize ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getDifferentialSize = function getDifferentialSize () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).getDifferential();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).getDifferential();
else throw new Error('This node does not have access to a size component');
}; | Returns the differential size of the node
@method
@return {Float32Array} a vector 3 showing the current differential size | getDifferentialSize ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getAbsoluteSize = function getAbsoluteSize () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).getAbsolute();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).getAbsolute();
else throw new Error('This node does not have access to a size component');
}; | Returns the absolute size of the node
@method
@return {Float32Array} a vector 3 showing the current absolute size of the node | getAbsoluteSize ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getRenderSize = function getRenderSize () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).getRender();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).getRender();
else throw new Error('This node does not have access to a size component');
}; | Returns the current Render Size of the node. Note that the render size
is asynchronous (will always be one frame behind) and needs to be explicitely
calculated by setting the proper size mode.
@method
@return {Float32Array} a vector 3 showing the current render size | getRenderSize ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getSize = function getSize () {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
return this.getComponent(this._sizeID).get();
else if (this.isMounted())
return SizeSystem.get(this.getLocation()).get();
else throw new Error('This node does not have access to a size component');
}; | Returns the external size of the node
@method
@return {Float32Array} a vector 3 of the final calculated side of the node | getSize ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getTransform = function getTransform () {
return TransformSystem.get(this.getLocation());
}; | Returns the current world transform of the node
@method
@return {Float32Array} a 16 value transform | getTransform ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getUIEvents = function getUIEvents () {
return this._UIEvents;
}; | Get the list of the UI Events that are currently associated with this node
@method
@return {Array} an array of strings representing the current subscribed UI event of this node | getUIEvents ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.addChild = function addChild (child) {
var index = child ? this._children.indexOf(child) : -1;
child = child ? child : new Node();
if (index === -1) {
index = this._freedChildIndicies.length ?
this._freedChildIndicies.pop() : this._children.length;
this._children[index] = child;
this._fullChildren.push(child);
}
if (this.isMounted())
child.mount(this.getLocation() + '/' + index);
return child;
}; | Adds a new child to this node. If this method is called with no argument it will
create a new node, however it can also be called with an existing node which it will
append to the node that this method is being called on. Returns the new or passed in node.
@method
@param {Node | void} child the node to appended or no node to create a new node.
@return {Node} the appended node. | addChild ( child ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.removeChild = function removeChild (child) {
var index = this._children.indexOf(child);
if (index > - 1) {
this._freedChildIndicies.push(index);
this._children[index] = null;
if (child.isMounted()) child.dismount();
var fullChildrenIndex = this._fullChildren.indexOf(child);
var len = this._fullChildren.length;
var i = 0;
for (i = fullChildrenIndex; i < len-1; i++)
this._fullChildren[i] = this._fullChildren[i + 1];
this._fullChildren.pop();
return true;
}
else {
return false;
}
}; | Removes a child node from another node. The passed in node must be
a child of the node that this method is called upon.
@method
@param {Node} child node to be removed
@return {Boolean} whether or not the node was successfully removed | removeChild ( child ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.addComponent = function addComponent (component) {
var index = this._components.indexOf(component);
if (index === -1) {
index = this._freedComponentIndicies.length ? this._freedComponentIndicies.pop() : this._components.length;
this._components[index] = component;
if (this.isMounted() && component.onMount)
component.onMount(this, index);
if (this.isShown() && component.onShow)
component.onShow();
}
return index;
}; | Each component can only be added once per node.
@method addComponent
@param {Object} component A component to be added.
@return {Number} index The index at which the component has been
registered. Indices aren't necessarily
consecutive. | addComponent ( component ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getComponent = function getComponent (index) {
return this._components[index];
}; | @method getComponent
@param {Number} index Index at which the component has been registered
(using `Node#addComponent`).
@return {*} The component registered at the passed in index (if
any). | getComponent ( index ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.removeComponent = function removeComponent (component) {
var index = this._components.indexOf(component);
if (index !== -1) {
this._freedComponentIndicies.push(index);
if (this.isShown() && component.onHide)
component.onHide();
if (this.isMounted() && component.onDismount)
component.onDismount();
this._components[index] = null;
}
return component;
}; | Removes a previously via {@link Node#addComponent} added component.
@method removeComponent
@param {Object} component An component that has previously been added
using {@link Node#addComponent}.
@return {Node} this | removeComponent ( component ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.removeUIEvent = function removeUIEvent (eventName) {
var UIEvents = this.getUIEvents();
var components = this._components;
var component;
var index = UIEvents.indexOf(eventName);
if (index !== -1) {
UIEvents.splice(index, 1);
for (var i = 0, len = components.length ; i < len ; i++) {
component = components[i];
if (component && component.onRemoveUIEvent) component.onRemoveUIEvent(eventName);
}
}
}; | Removes a node's subscription to a particular UIEvent. All components
on the node will have the opportunity to remove all listeners depending
on this event.
@method
@param {String} eventName the name of the event
@return {undefined} undefined | removeUIEvent ( eventName ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.addUIEvent = function addUIEvent (eventName) {
var UIEvents = this.getUIEvents();
var components = this._components;
var component;
var added = UIEvents.indexOf(eventName) !== -1;
if (!added) {
UIEvents.push(eventName);
for (var i = 0, len = components.length ; i < len ; i++) {
component = components[i];
if (component && component.onAddUIEvent) component.onAddUIEvent(eventName);
}
}
return this;
}; | Subscribes a node to a UI Event. All components on the node
will have the opportunity to begin listening to that event
and alerting the scene graph.
@method
@param {String} eventName the name of the event
@return {Node} this | addUIEvent ( eventName ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._requestUpdate = function _requestUpdate (force) {
if (force || !this._requestingUpdate) {
if (this._updater)
this._updater.requestUpdate(this);
this._requestingUpdate = true;
}
}; | Private method for the Node to request an update for itself.
@method
@private
@param {Boolean} force whether or not to force the update
@return {undefined} undefined | _requestUpdate ( force ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype._vecOptionalSet = function _vecOptionalSet (vec, index, val) {
if (val != null && vec[index] !== val) {
vec[index] = val;
if (!this._requestingUpdate) this._requestUpdate();
return true;
}
return false;
}; | Private method to set an optional value in an array, and
request an update if this changes the value of the array.
@method
@param {Array} vec the array to insert the value into
@param {Number} index the index at which to insert the value
@param {Any} val the value to potentially insert (if not null or undefined)
@return {Boolean} whether or not a new value was inserted. | _vecOptionalSet ( vec , index , val ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.show = function show () {
Dispatch.show(this.getLocation());
this._shown = true;
return this;
}; | Shows the node, which is to say, calls onShow on all of the
node's components. Renderable components can then issue the
draw commands necessary to be shown.
@method
@return {Node} this | show ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.hide = function hide () {
Dispatch.hide(this.getLocation());
this._shown = false;
return this;
}; | Hides the node, which is to say, calls onHide on all of the
node's components. Renderable components can then issue
the draw commands necessary to be hidden
@method
@return {Node} this | hide ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setAlign = function setAlign (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setAlign(x, y, z);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setAlign(x, y, z);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the align value of the node. Will call onAlignChange
on all of the Node's components.
@method
@param {Number} x Align value in the x dimension.
@param {Number} y Align value in the y dimension.
@param {Number} z Align value in the z dimension.
@return {Node} this | setAlign ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setMountPoint = function setMountPoint (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setMountPoint(x, y, z);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setMountPoint(x, y, z);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the mount point value of the node. Will call onMountPointChange
on all of the node's components.
@method
@param {Number} x MountPoint value in x dimension
@param {Number} y MountPoint value in y dimension
@param {Number} z MountPoint value in z dimension
@return {Node} this | setMountPoint ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setOrigin = function setOrigin (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setOrigin(x, y, z);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setOrigin(x, y, z);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the origin value of the node. Will call onOriginChange
on all of the node's components.
@method
@param {Number} x Origin value in x dimension
@param {Number} y Origin value in y dimension
@param {Number} z Origin value in z dimension
@return {Node} this | setOrigin ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setPosition = function setPosition (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setPosition(x, y, z);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setPosition(x, y, z);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the position of the node. Will call onPositionChange
on all of the node's components.
@method
@param {Number} x Position in x
@param {Number} y Position in y
@param {Number} z Position in z
@return {Node} this | setPosition ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setRotation = function setRotation (x, y, z, w) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setRotation(x, y, z, w);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setRotation(x, y, z, w);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the rotation of the node. Will call onRotationChange
on all of the node's components. This method takes either
Euler angles or a quaternion. If the fourth argument is undefined
Euler angles are assumed.
@method
@param {Number} x Either the rotation around the x axis or the magnitude in x of the axis of rotation.
@param {Number} y Either the rotation around the y axis or the magnitude in y of the axis of rotation.
@param {Number} z Either the rotation around the z axis or the magnitude in z of the axis of rotation.
@param {Number|undefined} w the amount of rotation around the axis of rotation, if a quaternion is specified.
@return {Node} this | setRotation ( x , y , z , w ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setScale = function setScale (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._transformID).setScale(x, y, z);
else if (this.isMounted())
TransformSystem.get(this.getLocation()).setScale(x, y, z);
else throw new Error('This node does not have access to a transform component');
return this;
}; | Sets the scale of the node. The default value is 1 in all dimensions.
The node's components will have onScaleChanged called on them.
@method
@param {Number} x Scale value in x
@param {Number} y Scale value in y
@param {Number} z Scale value in z
@return {Node} this | setScale ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setOpacity = function setOpacity (val) {
if (val !== this._opacity) {
this._opacity = val;
if (!this._requestingUpdate) this._requestUpdate();
var i = 0;
var list = this._components;
var len = list.length;
var item;
for (; i < len ; i++) {
item = list[i];
if (item && item.onOpacityChange) item.onOpacityChange(val);
}
}
return this;
}; | Sets the value of the opacity of this node. All of the node's
components will have onOpacityChange called on them/
@method
@param {Number} val Value of the opacity. 1 is the default.
@return {Node} this | setOpacity ( val ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setSizeMode = function setSizeMode (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._sizeID).setSizeMode(x, y, z);
else if (this.isMounted())
SizeSystem.get(this.getLocation()).setSizeMode(x, y, z);
else throw new Error('This node does not have access to a size component');
return this;
}; | Sets the size mode being used for determining the node's final width, height
and depth.
Size modes are a way to define the way the node's size is being calculated.
Size modes are enums set on the {@link Size} constructor (and aliased on
the Node).
@example
node.setSizeMode(Node.RELATIVE_SIZE, Node.ABSOLUTE_SIZE, Node.ABSOLUTE_SIZE);
// Instead of null, any proportional height or depth can be passed in, since
// it would be ignored in any case.
node.setProportionalSize(0.5, null, null);
node.setAbsoluteSize(null, 100, 200);
@method setSizeMode
@param {SizeMode} x The size mode being used for determining the size in
x direction ("width").
@param {SizeMode} y The size mode being used for determining the size in
y direction ("height").
@param {SizeMode} z The size mode being used for determining the size in
z direction ("depth").
@return {Node} this | setSizeMode ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setProportionalSize = function setProportionalSize (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._sizeID).setProportional(x, y, z);
else if (this.isMounted())
SizeSystem.get(this.getLocation()).setProportional(x, y, z);
else throw new Error('This node does not have access to a size component');
return this;
}; | A proportional size defines the node's dimensions relative to its parents
final size.
Proportional sizes need to be within the range of [0, 1].
@method setProportionalSize
@param {Number} x x-Size in pixels ("width").
@param {Number} y y-Size in pixels ("height").
@param {Number} z z-Size in pixels ("depth").
@return {Node} this | setProportionalSize ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setDifferentialSize = function setDifferentialSize (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._sizeID).setDifferential(x, y, z);
else if (this.isMounted())
SizeSystem.get(this.getLocation()).setDifferential(x, y, z);
else throw new Error('This node does not have access to a size component');
return this;
}; | Differential sizing can be used to add or subtract an absolute size from an
otherwise proportionally sized node.
E.g. a differential width of `-10` and a proportional width of `0.5` is
being interpreted as setting the node's size to 50% of its parent's width
*minus* 10 pixels.
@method setDifferentialSize
@param {Number} x x-Size to be added to the relatively sized node in
pixels ("width").
@param {Number} y y-Size to be added to the relatively sized node in
pixels ("height").
@param {Number} z z-Size to be added to the relatively sized node in
pixels ("depth").
@return {Node} this | setDifferentialSize ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.setAbsoluteSize = function setAbsoluteSize (x, y, z) {
if (!this.constructor.NO_DEFAULT_COMPONENTS)
this.getComponent(this._sizeID).setAbsolute(x, y, z);
else if (this.isMounted())
SizeSystem.get(this.getLocation()).setAbsolute(x, y, z);
else throw new Error('This node does not have access to a size component');
return this;
}; | Sets the node's size in pixels, independent of its parent.
@method setAbsoluteSize
@param {Number} x x-Size in pixels ("width").
@param {Number} y y-Size in pixels ("height").
@param {Number} z z-Size in pixels ("depth").
@return {Node} this | setAbsoluteSize ( x , y , z ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getFrame = function getFrame () {
return this._updater.getFrame();
}; | Method for getting the current frame. Will be deprecated.
@method
@return {Number} current frame | getFrame ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.getComponents = function getComponents () {
return this._components;
}; | returns an array of the components currently attached to this
node.
@method getComponents
@return {Array} list of components. | getComponents ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.update = function update (time){
this._inUpdate = true;
var nextQueue = this._nextUpdateQueue;
var queue = this._updateQueue;
var item;
while (nextQueue.length) queue.unshift(nextQueue.pop());
while (queue.length) {
item = this._components[queue.shift()];
if (item && item.onUpdate) item.onUpdate(time);
}
this._inUpdate = false;
this._requestingUpdate = false;
if (!this.isMounted()) {
// last update
this._parent = null;
this._id = null;
}
else if (this._nextUpdateQueue.length) {
this._updater.requestUpdateOnNextTick(this);
this._requestingUpdate = true;
}
return this;
}; | Enters the node's update phase while updating its own spec and updating its components.
@method update
@param {Number} time high-resolution timestamp, usually retrieved using
requestAnimationFrame
@return {Node} this | update ( time ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.mount = function mount (path) {
if (this.isMounted())
throw new Error('Node is already mounted at: ' + this.getLocation());
if (!this.constructor.NO_DEFAULT_COMPONENTS){
TransformSystem.registerTransformAtPath(path, this.getComponent(this._transformID));
SizeSystem.registerSizeAtPath(path, this.getComponent(this._sizeID));
}
else {
TransformSystem.registerTransformAtPath(path);
SizeSystem.registerSizeAtPath(path);
}
Dispatch.mount(path, this);
if (!this._requestingUpdate) this._requestUpdate();
return this;
}; | Mounts the node and therefore its subtree by setting it as a child of the
passed in parent.
@method mount
@param {String} path unique path of node (e.g. `body/0/1`)
@return {Node} this | mount ( path ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
Node.prototype.dismount = function dismount () {
if (!this.isMounted())
throw new Error('Node is not mounted');
var path = this.getLocation();
TransformSystem.deregisterTransformAtPath(path);
SizeSystem.deregisterSizeAtPath(path);
Dispatch.dismount(path);
if (!this._requestingUpdate) this._requestUpdate();
}; | Dismounts (detaches) the node from the scene graph by removing it as a
child of its parent.
@method
@return {Node} this | dismount ( ) | javascript | Famous/engine | core/Node.js | https://github.com/Famous/engine/blob/master/core/Node.js | MIT |
function Clock () {
this._time = 0;
this._frame = 0;
this._timerQueue = [];
this._updatingIndex = 0;
this._scale = 1;
this._scaledTime = this._time;
} | Equivalent of an Engine in the Worker Thread. Used to synchronize and manage
time across different Threads.
@class Clock
@constructor
@private | Clock ( ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.setScale = function setScale (scale) {
this._scale = scale;
return this;
}; | Sets the scale at which the clock time is passing.
Useful for slow-motion or fast-forward effects.
`1` means no time scaling ("realtime"),
`2` means the clock time is passing twice as fast,
`0.5` means the clock time is passing two times slower than the "actual"
time at which the Clock is being updated via `.step`.
Initally the clock time is not being scaled (factor `1`).
@method setScale
@chainable
@param {Number} scale The scale at which the clock time is passing.
@return {Clock} this | setScale ( scale ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.getScale = function getScale () {
return this._scale;
}; | @method getScale
@return {Number} scale The scale at which the clock time is passing. | getScale ( ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.step = function step (time) {
this._frame++;
this._scaledTime = this._scaledTime + (time - this._time)*this._scale;
this._time = time;
for (var i = 0; i < this._timerQueue.length; i++) {
if (this._timerQueue[i](this._scaledTime)) {
this._timerQueue.splice(i, 1);
}
}
return this;
}; | Updates the internal clock time.
@method step
@chainable
@param {Number} time high resolution timestamp used for invoking the
`update` method on all registered objects
@return {Clock} this | step ( time ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.now = function now () {
return this._scaledTime;
}; | Returns the internal clock time.
@method now
@return {Number} time high resolution timestamp used for invoking the
`update` method on all registered objects | now ( ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.getFrame = function getFrame () {
return this._frame;
}; | Returns the number of frames elapsed so far.
@method getFrame
@return {Number} frames | getFrame ( ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.setTimeout = function (callback, delay) {
var params = Array.prototype.slice.call(arguments, 2);
var startedAt = this._time;
var timer = function(time) {
if (time - startedAt >= delay) {
callback.apply(null, params);
return true;
}
return false;
};
this._timerQueue.push(timer);
return timer;
}; | Wraps a function to be invoked after a certain amount of time.
After a set duration has passed, it executes the function and
removes it as a listener to 'prerender'.
@method setTimeout
@param {Function} callback function to be run after a specified duration
@param {Number} delay milliseconds from now to execute the function
@return {Function} timer function used for Clock#clearTimer | Clock.prototype.setTimeout ( callback , delay ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.setInterval = function setInterval(callback, delay) {
var params = Array.prototype.slice.call(arguments, 2);
var startedAt = this._time;
var timer = function(time) {
if (time - startedAt >= delay) {
callback.apply(null, params);
startedAt = time;
}
return false;
};
this._timerQueue.push(timer);
return timer;
}; | Wraps a function to be invoked after a certain amount of time.
After a set duration has passed, it executes the function and
resets the execution time.
@method setInterval
@param {Function} callback function to be run after a specified duration
@param {Number} delay interval to execute function in milliseconds
@return {Function} timer function used for Clock#clearTimer | setInterval ( callback , delay ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
Clock.prototype.clearTimer = function (timer) {
var index = this._timerQueue.indexOf(timer);
if (index !== -1) {
this._timerQueue.splice(index, 1);
}
return this;
}; | Removes previously via `Clock#setTimeout` or `Clock#setInterval`
registered callback function
@method clearTimer
@chainable
@param {Function} timer previously by `Clock#setTimeout` or
`Clock#setInterval` returned callback function
@return {Clock} this | Clock.prototype.clearTimer ( timer ) | javascript | Famous/engine | core/Clock.js | https://github.com/Famous/engine/blob/master/core/Clock.js | MIT |
hasTrailingSlash: function hasTrailingSlash (path) {
return path[path.length - 1] === '/';
}, | determines if the passed in path has a trailing slash. Paths of the form
'body/0/1/' return true, while paths of the form 'body/0/1' return false.
@method
@param {String} path the path
@return {Boolean} whether or not the path has a trailing slash | hasTrailingSlash ( path ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
depth: function depth (path) {
var count = 0;
var length = path.length;
var len = this.hasTrailingSlash(path) ? length - 1 : length;
var i = 0;
for (; i < len ; i++) count += path[i] === '/' ? 1 : 0;
return count;
}, | Returns the depth in the tree this path represents. Essentially counts
the slashes ignoring a trailing slash.
@method
@param {String} path the path
@return {Number} the depth in the tree that this path represents | depth ( path ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
index: function index (path) {
var length = path.length;
var len = this.hasTrailingSlash(path) ? length - 1 : length;
while (len--) if (path[len] === '/') break;
var result = parseInt(path.substring(len + 1));
return isNaN(result) ? 0 : result;
}, | Gets the position of this path in relation to its siblings.
@method
@param {String} path the path
@return {Number} the index of this path in relation to its siblings. | index ( path ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
isChildOf: function isChildOf (child, parent) {
return this.isDescendentOf(child, parent) && this.depth(child) === this.depth(parent) + 1;
}, | Determines whether or not the first argument path is the direct child
of the second argument path.
@method
@param {String} child the path that may be a child
@param {String} parent the path that may be a parent
@return {Boolean} whether or not the first argument path is a child of the second argument path | isChildOf ( child , parent ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
isDescendentOf: function isDescendentOf(child, parent) {
if (child === parent) return false;
child = this.hasTrailingSlash(child) ? child : child + '/';
parent = this.hasTrailingSlash(parent) ? parent : parent + '/';
return this.depth(parent) < this.depth(child) && child.indexOf(parent) === 0;
}, | Returns true if the first argument path is a descendent of the second argument path.
@method
@param {String} child potential descendent path
@param {String} parent potential ancestor path
@return {Boolean} whether or not the path is a descendent | isDescendentOf ( child , parent ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
getSelector: function getSelector(path) {
var index = path.indexOf('/');
return index === -1 ? path : path.substring(0, index);
} | returns the selector portion of the path.
@method
@param {String} path the path
@return {String} the selector portion of the path. | getSelector ( path ) | javascript | Famous/engine | core/Path.js | https://github.com/Famous/engine/blob/master/core/Path.js | MIT |
function TransformSystem () {
this.pathStore = new PathStore();
} | The transform class is responsible for calculating the transform of a particular
node from the data on the node and its parent
@constructor {TransformSystem} | TransformSystem ( ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.registerTransformAtPath = function registerTransformAtPath (path, transform) {
if (!PathUtils.depth(path))
return this.pathStore.insert(path, transform ? transform : new Transform());
var parent = this.pathStore.get(PathUtils.parent(path));
if (!parent) throw new Error(
'No parent transform registered at expected path: ' + PathUtils.parent(path)
);
if (transform) transform.setParent(parent);
this.pathStore.insert(path, transform ? transform : new Transform(parent));
}; | registers a new Transform for the given path. This transform will be updated
when the TransformSystem updates.
@method registerTransformAtPath
@return {undefined} undefined
@param {String} path for the transform to be registered to.
@param {Transform | undefined} transform optional transform to register. | registerTransformAtPath ( path , transform ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.deregisterTransformAtPath = function deregisterTransformAtPath (path) {
this.pathStore.remove(path);
}; | deregisters a transform registered at the given path.
@method deregisterTransformAtPath
@return {void}
@param {String} path at which to register the transform | deregisterTransformAtPath ( path ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.makeBreakPointAt = function makeBreakPointAt (path) {
var transform = this.pathStore.get(path);
if (!transform) throw new Error('No transform Registered at path: ' + path);
transform.setBreakPoint();
}; | Method which will make the transform currently stored at the given path a breakpoint.
A transform being a breakpoint means that both a local and world transform will be calculated
for that point. The local transform being the concatinated transform of all ancestor transforms up
until the nearest breakpoint, and the world being the concatinated transform of all ancestor transforms.
This method throws if no transform is at the provided path.
@method
@param {String} path The path at which to turn the transform into a breakpoint
@return {undefined} undefined | makeBreakPointAt ( path ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.makeCalculateWorldMatrixAt = function makeCalculateWorldMatrixAt (path) {
var transform = this.pathStore.get(path);
if (!transform) throw new Error('No transform Registered at path: ' + path);
transform.setCalculateWorldMatrix();
}; | Method that will make the transform at this location calculate a world matrix.
@method
@param {String} path The path at which to make the transform calculate a world matrix
@return {undefined} undefined | makeCalculateWorldMatrixAt ( path ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.get = function get (path) {
return this.pathStore.get(path);
}; | Returns the instance of the transform class associated with the given path,
or undefined if no transform is associated.
@method
@param {String} path The path to lookup
@return {Transform | undefined} the transform at that path is available, else undefined. | get ( path ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
TransformSystem.prototype.update = function update () {
var transforms = this.pathStore.getItems();
var paths = this.pathStore.getPaths();
var transform;
var changed;
var node;
var vectors;
var offsets;
var components;
for (var i = 0, len = transforms.length ; i < len ; i++) {
node = Dispatch.getNode(paths[i]);
if (!node) continue;
components = node.getComponents();
transform = transforms[i];
vectors = transform.vectors;
offsets = transform.offsets;
if (offsets.alignChanged) alignChanged(node, components, offsets);
if (offsets.mountPointChanged) mountPointChanged(node, components, offsets);
if (offsets.originChanged) originChanged(node, components, offsets);
if (vectors.positionChanged) positionChanged(node, components, vectors);
if (vectors.rotationChanged) rotationChanged(node, components, vectors);
if (vectors.scaleChanged) scaleChanged(node, components, vectors);
if ((changed = transform.calculate(node))) {
transformChanged(node, components, transform);
if (changed & Transform.LOCAL_CHANGED) localTransformChanged(node, components, transform.getLocalTransform());
if (changed & Transform.WORLD_CHANGED) worldTransformChanged(node, components, transform.getWorldTransform());
}
}
}; | update is called when the transform system requires an update.
It traverses the transform array and evaluates the necessary transforms
in the scene graph with the information from the corresponding node
in the scene graph
@method update
@return {undefined} undefined | update ( ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function alignChanged (node, components, offsets) {
var x = offsets.align[0];
var y = offsets.align[1];
var z = offsets.align[2];
if (node.onAlignChange) node.onAlignChange(x, y, z);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onAlignChange)
components[i].onAlignChange(x, y, z);
offsets.alignChanged = false;
} | Private method to call when align changes. Triggers 'onAlignChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to call onAlignChange if necessary
@param {Array} components the components on which to call onAlignChange if necessary
@param {Object} offsets the set of offsets from the transform
@return {undefined} undefined | alignChanged ( node , components , offsets ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function mountPointChanged (node, components, offsets) {
var x = offsets.mountPoint[0];
var y = offsets.mountPoint[1];
var z = offsets.mountPoint[2];
if (node.onMountPointChange) node.onMountPointChange(x, y, z);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onMountPointChange)
components[i].onMountPointChange(x, y, z);
offsets.mountPointChanged = false;
} | Private method to call when MountPoint changes. Triggers 'onMountPointChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Object} offsets the set of offsets from the transform
@return {undefined} undefined | mountPointChanged ( node , components , offsets ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function originChanged (node, components, offsets) {
var x = offsets.origin[0];
var y = offsets.origin[1];
var z = offsets.origin[2];
if (node.onOriginChange) node.onOriginChange(x, y, z);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onOriginChange)
components[i].onOriginChange(x, y, z);
offsets.originChanged = false;
} | Private method to call when Origin changes. Triggers 'onOriginChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Object} offsets the set of offsets from the transform
@return {undefined} undefined | originChanged ( node , components , offsets ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function positionChanged (node, components, vectors) {
var x = vectors.position[0];
var y = vectors.position[1];
var z = vectors.position[2];
if (node.onPositionChange) node.onPositionChange(x, y, z);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onPositionChange)
components[i].onPositionChange(x, y, z);
vectors.positionChanged = false;
} | Private method to call when Position changes. Triggers 'onPositionChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Object} vectors the set of vectors from the transform
@return {undefined} undefined | positionChanged ( node , components , vectors ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function rotationChanged (node, components, vectors) {
var x = vectors.rotation[0];
var y = vectors.rotation[1];
var z = vectors.rotation[2];
var w = vectors.rotation[3];
if (node.onRotationChange) node.onRotationChange(x, y, z, w);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onRotationChange)
components[i].onRotationChange(x, y, z, w);
vectors.rotationChanged = false;
} | Private method to call when Rotation changes. Triggers 'onRotationChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Object} vectors the set of vectors from the transform
@return {undefined} undefined | rotationChanged ( node , components , vectors ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function scaleChanged (node, components, vectors) {
var x = vectors.scale[0];
var y = vectors.scale[1];
var z = vectors.scale[2];
if (node.onScaleChange) node.onScaleChange(x, y, z);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onScaleChange)
components[i].onScaleChange(x, y, z);
vectors.scaleChanged = false;
} | Private method to call when Scale changes. Triggers 'onScaleChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Object} vectors the set of vectors from the transform
@return {undefined} undefined | scaleChanged ( node , components , vectors ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function transformChanged (node, components, transform) {
if (node.onTransformChange) node.onTransformChange(transform);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onTransformChange)
components[i].onTransformChange(transform);
} | Private method to call when either the Local or World Transform changes.
Triggers 'onTransformChange' methods on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Transform} transform the transform class that changed
@return {undefined} undefined | transformChanged ( node , components , transform ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function localTransformChanged (node, components, transform) {
if (node.onLocalTransformChange) node.onLocalTransformChange(transform);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onLocalTransformChange)
components[i].onLocalTransformChange(transform);
} | Private method to call when the local transform changes. Triggers 'onLocalTransformChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Array} transform the local transform
@return {undefined} undefined | localTransformChanged ( node , components , transform ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function worldTransformChanged (node, components, transform) {
if (node.onWorldTransformChange) node.onWorldTransformChange(transform);
for (var i = 0, len = components.length ; i < len ; i++)
if (components[i] && components[i].onWorldTransformChange)
components[i].onWorldTransformChange(transform);
} | Private method to call when the world transform changes. Triggers 'onWorldTransformChange' methods
on the node and all of the node's components
@method
@private
@param {Node} node the node on which to trigger a change event if necessary
@param {Array} components the components on which to trigger a change event if necessary
@param {Array} transform the world transform
@return {undefined} undefined | worldTransformChanged ( node , components , transform ) | javascript | Famous/engine | core/TransformSystem.js | https://github.com/Famous/engine/blob/master/core/TransformSystem.js | MIT |
function Color(color, transition, cb) {
this._r = new Transitionable(0);
this._g = new Transitionable(0);
this._b = new Transitionable(0);
this._opacity = new Transitionable(1);
if (color) this.set(color, transition, cb);
} | @class Color
@constructor
@param {Color|String|Array} color Optional argument for setting color using Hex, a Color instance, color name or RGB.
@param {Object} transition Optional transition.
@param {Function} cb Callback function to be called on completion of the initial transition.
@return {undefined} undefined | Color ( color , transition , cb ) | javascript | Famous/engine | utilities/Color.js | https://github.com/Famous/engine/blob/master/utilities/Color.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.