Cone
Summary
Manage 3d Cone with a simple API
Based on BabylonJS
Constructor
Cone
Syntax
Summary
Parameters:
-
scene
BABYLON.Scene -
[options]
Object optional-
[name]
String optionalName of the cone instance
-
[tessellation=30]
Number optionalNumber of faces of the cylinder
-
[moveStep=0.1]
Number optionalHow much the cone will move at each move call
-
[turnStep=0.1]
Number optionalHow much the cone will turn at each turn call (in rad)
-
[eyeSize=1.5]
Number optionalEye size
-
[color]
String | Object optionalColor of the cone's sylinder (default : #900000) - can be in RGB or HEXA
-
[pickable=true]
Boolean optionalDefines if the cone is pickable
-
[$customOption]
Mixed optionalPass any custom option with a parameter's name starting by $
-
Returns:
Item Index
Methods
- addAlphaAnimation
- addBumpAnimation
- addColorAnimation
- addMethods static
- addScaleAnimation
- addWidenEyesAnimation
- animate
- animateAlpha
- animateColor deprecated
- animateScale
- animationMethodExists
- bump
- clearQueue
- clearQueues
- delay
- dequeue
- fadeIn
- fadeOut
- flushAnimationQueue
- follow
- getAnimationMethodQueueName
- getBottomDiameter
- getDistance
- getFullTail
- getHeight
- getMoveStep
- getPosition
- getTopDiameter
- getTurnStep
- hexToRgb
- intersectsCone
- intersectsGroundLimits
- isAnimationRunning
- isBumping
- isChangingAlpha
- isEyesWiden
- isRgb
- isTailRelated
- isWidenningEyes
- lookAt
- moveBack
- moveForward
- moveLeft
- moveRight
- moveTo
- queue
- registerToShadowGenerator
- removeAllAnimations
- removeAlphaAnimation
- removeBumpAnimation
- removeColorAnimation
- removeScaleAnimation
- removeWidenEyesAnimation
- resetBump
- resetWidenEyes
- setAlpha
- setColor
- setMoveStep
- setScale
- setTurnStep
- squint
- stopAllAnimationsRunning
- stopAnimateAlpha
- stopBump
- stopWidenEyes
- tail
- tailedCone
- tailingCone
- then
- toggleBump
- turnLeft
- turnRight
- unSquint
- unTail
- unWidenEyes
- widenEyes
Methods
addAlphaAnimation
Syntax
addAlphaAnimation
-
cone
-
options
Summary
Returns:
addBumpAnimation
Syntax
addBumpAnimation
-
cone
-
scale
Summary
Returns:
addColorAnimation
Syntax
addColorAnimation
-
cone
-
options
Summary
Returns:
addMethods
Syntax
addMethods
-
methodList
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
ObjectList of the methods to add to the cone list prototype
Returns:
Example:
//at the end of your file
Cone.addMethods(stateFullMethods);
Cone.List.addMethods(stateFullMethods);
addScaleAnimation
Syntax
addScaleAnimation
-
cone
-
options
Summary
Returns:
addWidenEyesAnimation
Syntax
addWidenEyesAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
animate
Syntax
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.
Returns:
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
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
[cylinder=true]
Boolean optionalTrue by default, if false, won't be affected
-
[leftEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
[rightEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
Returns:
animateColor
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
Returns:
animateScale
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
Returns:
bump
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
Returns:
delay
Syntax
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()
Returns:
dequeue
Syntax
Summary
Launches the next callback in the queue then removes it from the queue
Parameters:
-
queueName
String
Returns:
fadeIn
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
[cylinder=true]
Boolean optionalTrue by default, if false, won't be affected
-
[leftEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
[rightEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
Returns:
fadeOut
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
[cylinder=true]
Boolean optionalTrue by default, if false, won't be affected
-
[leftEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
[rightEye=true]
Boolean optionalTrue by default, if false, won't be affected
-
Returns:
flushAnimationQueue
Syntax
Summary
Stops all the animations on the fx queue then clears the queue (all other queues continue)
Returns:
getFullTail
Syntax
Summary
Returns a Cone.List of the cones tailing this one
Returns:
getPosition
Syntax
getPosition
()
BABYLON.Vector3
Summary
Returns cone position
Returns:
hexToRgb
Syntax
Summary
this method is inpired by http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
Parameters:
-
hex
String
Returns:
intersectsCone
Syntax
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:
-
cone
Cone
Returns:
intersectsGroundLimits
Syntax
Summary
Parameters:
-
ground
BABYLON.Mesh(plane)
-
replace
Booleanif you wan't not only to check the limit but also keep the cone inside it
Returns:
isAnimationRunning
Syntax
Summary
Returns true if an fx animation is running
Returns:
isChangingAlpha
Syntax
Summary
Returns true if alpha is animating on the cone
Returns:
isEyesWiden
Syntax
Summary
Returns true if the cone has its eyes widen
Returns:
isTailRelated
Syntax
Summary
Returns true if this cone is n a tail in a way or an other
Returns:
isWidenningEyes
Syntax
Summary
Returns true if the cone is widenning eyes
Returns:
moveTo
Syntax
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 optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one (
.moveTo()
is on themove
queue, not thefx
queue as the other animations, so you can run them in parallel of moveTo)
-
Returns:
queue
Syntax
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:
Returns:
registerToShadowGenerator
Syntax
Summary
Registers the cone to a BABYLON.ShadowGenerator to be able to render shadows on the shadow map
Parameters:
-
shadowGenerator
BABYLON.ShadowGenerator
Returns:
removeAllAnimations
Syntax
removeAllAnimations
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
removeAlphaAnimation
Syntax
removeAlphaAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
removeBumpAnimation
Syntax
removeBumpAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
removeColorAnimation
Syntax
removeColorAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
removeScaleAnimation
Syntax
removeScaleAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
removeWidenEyesAnimation
Syntax
removeWidenEyesAnimation
-
cone
Summary
Parameters:
-
cone
Cone
Returns:
squint
Syntax
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:
tail
Syntax
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:
Returns:
tailedCone
Syntax
Summary
Returns the cone this cone is tailed by (or false if none)
tailingCone
Syntax
Summary
Returns the cone this cone is tailing (or false if none)
then
Syntax
Summary
Adds callback to the last used queue
Parameters:
-
callback
Functionfunction(next){}
Returns:
Example:
var myCone = new Cone(scene);
myCone
.fadeOut()
.fadeIn()
.delay(1000)
.widenEyes()
.unWidenEyes()
.then(function(next){myCone.setColor('#900000'); next()})
.bump();
unSquint
Syntax
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:
unWidenEyes
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
[full=false]
Boolean optionalIf true, runs the full animation (openning and closing eyes)
-
[close=true]
Boolean optionalIf true, runs only the close eyes part of the animation (by default, does that on unWidenEyes)
-
Returns:
widenEyes
Syntax
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 optional3 possibilities :
true
will loop the animation until you stop itfalse
will play the animation only once- a number will play the animation a number of times
-
[callback=null]
Function optionalwill run your callback at the end of the animation :
function(cone){}
-
[delay=0]
Number optionalDelay between the end of the animation and the execution of the callback (and potentionally the next animation in the queue)
-
[break=false]
Boolean optionalIf true cancels all animations in the queue before running this one
-
[full=false]
Boolean optionalIf true, runs the full animation (openning and closing eyes)
-
[close=false]
Boolean optionalIf true, runs only the close eyes part of the animation (by default, only opens eyes)
-
Returns:
Properties
_size
Syntax
Summary
Original sizes