Cone.js

API Docs for: 1.0.1
Show:

Cone

Module: Cone

Summary

Manage 3d Cone with a simple API

Based on BabylonJS

Constructor

Cone

Syntax

Cone

(
  • scene
  • [options]
)
Cone

Summary

Parameters:

  • scene BABYLON.Scene
  • [options] Object optional
    • [name] String optional

      Name of the cone instance

    • [tessellation=30] Number optional

      Number of faces of the cylinder

    • [moveStep=0.1] Number optional

      How much the cone will move at each move call

    • [turnStep=0.1] Number optional

      How much the cone will turn at each turn call (in rad)

    • [eyeSize=1.5] Number optional

      Eye size

    • [color] String | Object optional

      Color of the cone's sylinder (default : #900000) - can be in RGB or HEXA

    • [pickable=true] Boolean optional

      Defines if the cone is pickable

    • [$customOption] Mixed optional

      Pass any custom option with a parameter's name starting by $

Returns:

Cone:

Methods

addAlphaAnimation

Syntax

addAlphaAnimation

(
  • cone
  • options
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

addBumpAnimation

Syntax

addBumpAnimation

(
  • cone
  • scale
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

addColorAnimation

Syntax

addColorAnimation

(
  • cone
  • options
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

addMethods

Syntax

addMethods

(
  • methodList
)
Undefined static

Summary

This method is used internally to expose methods that are used both on Cone and Cone.List

You will use it when you make your own plugins to expose your own methods

Parameters:

  • methodList Object

    List of the methods to add to the cone list prototype

Returns:

Undefined:

Example:

//at the end of your file
                    Cone.addMethods(stateFullMethods);
                    Cone.List.addMethods(stateFullMethods);
                    

addScaleAnimation

Syntax

addScaleAnimation

(
  • cone
  • options
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

addWidenEyesAnimation

Syntax

addWidenEyesAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

animate

Syntax

animate

(
  • options
)
Cone chainable

Summary

Run any animate methods such as :

  • animateAlpha
  • animateScale
  • bump
  • fadeIn
  • fadeOut
  • unWidenEyes
  • widenEyes
  • moveTo

Just specify it in options.method. Those methods are also accessible directly via shorcuts on the Cone instance.

Parameters:

Returns:

Cone:

Example:

//you can use the .animate() dispatcher as well as the shortcuts, directly on a cone instance :
                    var myCone = new Cone(scene);
                    myCone
                     .fadeOut()
                     .fadeIn()
                     .delay(1000)
                     .widenEyes()
                     .unWidenEyes()
                     .then(function(next){myCone.setColor('#900000'); next()})
                     .bump();
                    

animateAlpha

Syntax

animateAlpha

(
  • [options]
)
Cone chainable

Summary

Animates the alpha of the cone

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [alpha=0] Number optional
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

    • [cylinder=true] Boolean optional

      True by default, if false, won't be affected

    • [leftEye=true] Boolean optional

      True by default, if false, won't be affected

    • [rightEye=true] Boolean optional

      True by default, if false, won't be affected

Returns:

Cone:

animateColor

Syntax

animateColor

(
  • options
)
Cone deprecated chainable

Summary

Animates the color of the cylinder of the cone

Can also be run via the .animate() dispatcher

Does not work for the moment

Parameters:

  • options Object
    • color Number
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

Returns:

Cone:

animateScale

Syntax

animateScale

(
  • [options]
)
Cone chainable

Summary

Animates the scale of the cone

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [scale=1] Number optional
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

Returns:

Cone:

animationMethodExists

Syntax

animationMethodExists

(
  • methodName
)
Boolean private

Summary

Parameters:

Returns:

bump

Syntax

bump

(
  • [options]
)
Cone chainable

Summary

Bumps the cone

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [scale=1.2] Number optional
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

Returns:

Cone:

clearQueue

Syntax

clearQueue

(
  • queueName
)
Cone chainable

Summary

Clears the queue

Parameters:

Returns:

Cone:

clearQueues

Syntax

clearQueues

() Cone chainable

Summary

Clears all the queues

Returns:

Cone:

delay

Syntax

delay

(
  • queueName
  • delay
)
Cone chainable

Summary

Delays the next event in the queue of "delay" ms.

You can force the queue name.

Can also be used without the queueName if you're alredy chaining on the right queue like : myCone.fadeOut().delay(2000).fadeIn()

Parameters:

Returns:

Cone:

dequeue

Syntax

dequeue

(
  • queueName
)
Cone chainable

Summary

Launches the next callback in the queue then removes it from the queue

Parameters:

Returns:

Cone:

fadeIn

Syntax

fadeIn

(
  • [options]
)
Cone chainable

Summary

Shortcut for animateAlpha(), from the current alpha to alpha=1

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

    • [cylinder=true] Boolean optional

      True by default, if false, won't be affected

    • [leftEye=true] Boolean optional

      True by default, if false, won't be affected

    • [rightEye=true] Boolean optional

      True by default, if false, won't be affected

Returns:

Cone:

fadeOut

Syntax

fadeOut

(
  • [options]
)
Cone chainable

Summary

Shortcut for animateAlpha(), from the current alpha to alpha=0

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [speed=3] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

    • [cylinder=true] Boolean optional

      True by default, if false, won't be affected

    • [leftEye=true] Boolean optional

      True by default, if false, won't be affected

    • [rightEye=true] Boolean optional

      True by default, if false, won't be affected

Returns:

Cone:

flushAnimationQueue

Syntax

flushAnimationQueue

() Cone chainable

Summary

Stops all the animations on the fx queue then clears the queue (all other queues continue)

Returns:

Cone:

follow

Syntax

follow

(
  • point
  • [callback]
)
Cone chainable

Summary

Moves the cone towards "point" of one moveStep

Parameters:

  • point BABYLON.Vector3 | Cone
  • [callback] Function optional

    callback executed when the cone gets to point function(point){}

Returns:

Cone:

getAnimationMethodQueueName

Syntax

getAnimationMethodQueueName

(
  • methodName
)
Boolean | String private

Summary

Parameters:

Returns:

getBottomDiameter

Syntax

getBottomDiameter

() Number

Summary

Returns:

getDistance

Syntax

getDistance

(
  • cone
)
Number

Summary

Parameters:

Returns:

getFullTail

Syntax

getFullTail

() Cone.List

Summary

Returns a Cone.List of the cones tailing this one

Returns:

getHeight

Syntax

getHeight

() Number

Summary

Returns:

getMoveStep

Syntax

getMoveStep

() Number

Summary

Returns:

getPosition

Syntax

getPosition

() BABYLON.Vector3

Summary

Returns cone position

Returns:

BABYLON.Vector3:

getTopDiameter

Syntax

getTopDiameter

() Number

Summary

Returns:

getTurnStep

Syntax

getTurnStep

() Number

Summary

Returns:

hexToRgb

Syntax

hexToRgb

(
  • hex
)
Object private

Parameters:

Returns:

intersectsCone

Syntax

intersectsCone

(
  • cone
)
Boolean

Summary

Checks if two cones intersect (based on the bottom diameter)

If a cone has been rescaled, it's taken account (although, if scaling x and z are different the bigger one is taken in account)

Parameters:

Returns:

intersectsGroundLimits

Syntax

intersectsGroundLimits

(
  • ground
  • replace
)
Boolean

Summary

Parameters:

  • ground BABYLON.Mesh

    (plane)

  • replace Boolean

    if you wan't not only to check the limit but also keep the cone inside it

Returns:

isAnimationRunning

Syntax

isAnimationRunning

() Boolean

Summary

Returns true if an fx animation is running

Returns:

isBumping

Syntax

isBumping

() Boolean

Summary

Returns:

isChangingAlpha

Syntax

isChangingAlpha

() Boolean

Summary

Returns true if alpha is animating on the cone

Returns:

isEyesWiden

Syntax

isEyesWiden

() Boolean

Summary

Returns true if the cone has its eyes widen

Returns:

isRgb

Syntax

isRgb

(
  • color
)
Boolean private

Summary

Parameters:

Returns:

isTailRelated

Syntax

isTailRelated

() Boolean

Summary

Returns true if this cone is n a tail in a way or an other

Returns:

isWidenningEyes

Syntax

isWidenningEyes

() Boolean

Summary

Returns true if the cone is widenning eyes

Returns:

lookAt

Syntax

lookAt

(
  • point
)
Cone chainable

Summary

Parameters:

  • point BABYLON.Vector3 | Cone

Returns:

Cone:

moveBack

Syntax

moveBack

() Cone chainable

Summary

Moves the cone backwards of one moveStep

Returns:

Cone:

moveForward

Syntax

moveForward

() Cone chainable

Summary

Moves the cone forward of one moveStep

Returns:

Cone:

moveLeft

Syntax

moveLeft

() Cone chainable

Summary

Moves the cone left of one moveStep

Returns:

Cone:

moveRight

Syntax

moveRight

() Cone chainable

Summary

Moves the cone right of one moveStep

Returns:

Cone:

moveTo

Syntax

moveTo

(
  • [options]
)
Cone chainable

Summary

Let's your cone move to a position.

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • position Cone | BABYLON.Vector3 | Object
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one (.moveTo() is on the move queue, not the fx queue as the other animations, so you can run them in parallel of moveTo)

Returns:

Cone:

queue

Syntax

queue

(
  • queueName
  • [callback]
)
Cone | Array chainable

Summary

  • Call it only with the queueName : Returns the queue.
  • Call it with queueName + callback : registers the callback in the queue. This callback has a "next" parameter to launch the next callback in the queue. Returns the cone to chain.
  • Call it with queueName + array of callback to replace the queue. Returns the cone to chain

Parameters:

  • queueName String
  • [callback] Function | Array optional

    use the next param like : function(next, currentCone){ myCone.fadeOut().delay(1000).then(next); }

Returns:

Cone | Array:

registerToShadowGenerator

Syntax

registerToShadowGenerator

(
  • shadowGenerator
)
Cone chainable

Summary

Registers the cone to a BABYLON.ShadowGenerator to be able to render shadows on the shadow map

Parameters:

  • shadowGenerator BABYLON.ShadowGenerator

Returns:

Cone:

removeAllAnimations

Syntax

removeAllAnimations

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

removeAlphaAnimation

Syntax

removeAlphaAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

removeBumpAnimation

Syntax

removeBumpAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

removeColorAnimation

Syntax

removeColorAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

removeScaleAnimation

Syntax

removeScaleAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

removeWidenEyesAnimation

Syntax

removeWidenEyesAnimation

(
  • cone
)
Undefined private

Summary

Parameters:

Returns:

Undefined:

resetBump

Syntax

resetBump

() Cone chainable

Summary

Reset cylinder to orginal scale and position

Returns:

Cone:

resetWidenEyes

Syntax

resetWidenEyes

() Cone chainable

Summary

Reset eyes to orginal scale and position

Returns:

Cone:

setAlpha

Syntax

setAlpha

(
  • alpha
)
Cone chainable

Summary

Sets the alpha on all the cone

Parameters:

Returns:

Cone:

setColor

Syntax

setColor

(
  • color
)
Cone chainable

Summary

Sets the color of the cylinder Accepts hexa or rgb color

Parameters:

Returns:

Cone:

setMoveStep

Syntax

setMoveStep

(
  • moveStep
)
Cone chainable

Summary

Parameters:

Returns:

Cone:

setScale

Syntax

setScale

(
  • scale
)
Cone chainable

Summary

Sets the scale on all the cone

Parameters:

Returns:

Cone:

setTurnStep

Syntax

setTurnStep

(
  • turnStep
)
Cone chainable

Summary

Parameters:

Returns:

Cone:

squint

Syntax

squint

() Boolean

Summary

Squints the eyes of one step Returns true if the eyes are not all squinted Returns false if they are and stop squint

Returns:

stopAllAnimationsRunning

Syntax

stopAllAnimationsRunning

() Cone chainable

Summary

Stops all the fx animations

Returns:

Cone:

stopAnimateAlpha

Syntax

stopAnimateAlpha

() Cone chainable

Summary

Returns:

Cone:

stopBump

Syntax

stopBump

() Cone chainable

Summary

Stops cylinder fx animation

Returns:

Cone:

stopWidenEyes

Syntax

stopWidenEyes

() Cone chainable

Summary

Stops eyes fx animation

Returns:

Cone:

tail

Syntax

tail

(
  • cone
  • [options]
)
Cone

Summary

  • Attaches this cone to the one passed in parameter
  • If you try to tail a cone already followed by another, your cone will follow the last one in the tail
  • Returns the cone you end up tailing

Parameters:

  • cone Cone
  • [options] Object optional
    • [distance] Number optional

      By default the sum of the radiuses of the cones

Returns:

Cone:

tailedCone

Syntax

tailedCone

() Boolean | Cone

Summary

Returns the cone this cone is tailed by (or false if none)

Returns:

tailingCone

Syntax

tailingCone

() Boolean | Cone

Summary

Returns the cone this cone is tailing (or false if none)

Returns:

then

Syntax

then

(
  • callback
)
Cone chainable

Summary

Adds callback to the last used queue

Parameters:

Returns:

Cone:

Example:

var myCone = new Cone(scene);
                    myCone
                     .fadeOut()
                     .fadeIn()
                     .delay(1000)
                     .widenEyes()
                     .unWidenEyes()
                     .then(function(next){myCone.setColor('#900000'); next()})
                     .bump();
                    

toggleBump

Syntax

toggleBump

(
  • options
)
Cone chainable

Summary

Parameters:

Returns:

Cone:

turnLeft

Syntax

turnLeft

() Cone chainable

Summary

Turns the cone left of one turnStep

Returns:

Cone:

turnRight

Syntax

turnRight

() Cone chainable

Summary

Turns the cone right of one turnStep

Returns:

Cone:

unSquint

Syntax

unSquint

() Boolean

Summary

Unsquints the eyes of one step Returns true if the eyes are not all unsquinted Returns false if they are and stop squint

Returns:

unTail

Syntax

unTail

() Cone

Summary

Detaches your cone, returns the cone it was tailing

Returns:

Cone:

unWidenEyes

Syntax

unWidenEyes

(
  • [options]
)
Cone chainable

Summary

Unwidens the eyes of the cone (and more)

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [speed=5] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

    • [full=false] Boolean optional

      If true, runs the full animation (openning and closing eyes)

    • [close=true] Boolean optional

      If true, runs only the close eyes part of the animation (by default, does that on unWidenEyes)

Returns:

Cone:

widenEyes

Syntax

widenEyes

(
  • [options]
)
Cone chainable

Summary

Widens the eyes of the cone (and more)

Can also be run via the .animate() dispatcher

Parameters:

  • [options] Object optional
    • [speed=5] Number optional
    • [loop=false] Boolean | Number optional

      3 possibilities :

      • true will loop the animation until you stop it
      • false will play the animation only once
      • a number will play the animation a number of times
    • [callback=null] Function optional

      will run your callback at the end of the animation : function(cone){}

    • [delay=0] Number optional

      Delay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)

    • [break=false] Boolean optional

      If true cancels all animations in the queue before running this one

    • [full=false] Boolean optional

      If true, runs the full animation (openning and closing eyes)

    • [close=false] Boolean optional

      If true, runs only the close eyes part of the animation (by default, only opens eyes)

Returns:

Cone:

Properties

_size

Syntax

_size

Object private

Summary

Original sizes

Sub-properties:

position.x

Syntax

position.x

Number

Summary

x postion of the cone in the space

position.y

Syntax

position.y

Number

Summary

y postion of the cone in the space

position.z

Syntax

position.z

Number

Summary

z postion of the cone in the space

rotation.x

Syntax

rotation.x

Number

Summary

x rotation of the cone in the space

rotation.y

Syntax

rotation.y

Number

Summary

y rotation of the cone in the space

rotation.z

Syntax

rotation.z

Number

Summary

z rotation of the cone in the space

scaling.x

Syntax

scaling.x

Number

Summary

x scaling of the cone

scaling.y

Syntax

scaling.y

Number

Summary

y scaling of the cone

scaling.z

Syntax

scaling.z

Number

Summary

z scaling of the cone