Library mec2.js
does not depend on other modules (except g2.js
). It particularly does not depend on the DOM.
{
id: String
nodes: Array
constraints: Array
loads: Array
shapes: Array
state: Object { valid: Boolean, direc: Number, … }
timer: Object { t: Number, dt: Number }
dof: Number
isActive: Boolean
init()
pose()
reset()
stop()
tick(dt:Number)
draw(g:Object)
}
{
id: String
base: Boolean
m: Number
x: Number
xt: Number
xtt: Number
y: Number
yt: Number
ytt: Number
Qx: Number
Qy: Number
}
{
id: String
p1: Node
p2: Node
ori: Object
len: Object
r: Number
rt: Number
rtt: Number
w: Number
wt: Number
wtt: Number
type: String
dof: Number
force: Number
moment: Number
}
{
id: String
type: String
}
depending on its load.type
loads become one of these objects:
{
id: String
type: 'force'
p: Node
value: Number
wref: Constraint
w0: Number
mode: String
len: Number
force: Number
Qx: Number
Qy: Number
}
{
id: String
type: 'spring'
p1: Node
p2: Node
k: Number
len0: Constraint
Qx: Number
Qy: Number
}
{
type: String
}
depending on its shape.type
shapes become one of these objects:
{
type: 'fix'
p: Node
w0: Number
}
{
type: 'flt'
p: Node
w0: Number
}
{
type: 'slider'
p: Node
wref: Constraint
w0: Number
}
{
type: 'bar'
p1: Node
p2: Node
}
{
type: 'beam'
p: Node
wref: Constraint
len: Number
}
{
type: 'wheel'
p: Node
wref: Constraint
w0: Number
r: Number
}
{
type: 'poly'
pts: Object | Array
p: Node
wref: Constraint
fill: web color
stroke: web color
}
{
type: 'img'
uri: String
p: Node | Object
b: Number
h: Number
sx: Number
sy: Number
sb: Number
sh: Number
xoff: Number
yoff: Number
wref: Constraint
w0: Number
scl: Number
}
- Moved everything graphics related (flags, colors) to
mec.core.show
. - Model now get e reference to their environment in
model.env
by passing it as a second parameter when extending (e.g.mec.model.extend(this.model,this);
). When an evnironment is set,mec.core.show
is copied as a property for that instance. If no environment is passed,mec.core.show
is used.
- Add
mec.core.linkage
for constraint and node graphics-flags. - Models now store label-flags in an
model.graphics
object that additionally has a memberlinkage
of typeobject
containing flags frommec.core.linkage
. - Fixed some bugs and added some missing properties in
asJSON
methods.
- Add
mec.shape.poly
for supporting polygonial shapes. - Add
mec.aly.r
,mec.aly.rt
andmec.aly.rtt
tomec.core.js
.
- Add
idloc
property tomec.constraint
. Value isleft
positiv (default)right
negativ- numeric value
[-1 .. 1]
- Draw references bug resolved.
- *.toJSON removed.
- add
stroke
property tomec.trace
elements. - changed source to current
mec.labels
convention. - introduce
mec.labels
structure with previous defaults for setting per JSON model. - depricate
mec.showNodeLabels
,mec.showConstraintLabels
,mec.showLoadLabels
. - decouple element prototype extension and initialization.
- static
mec.aly.*
for processingview.info
added. view.info
added.model.elementById
added.
trace
view added.- apply internal constraint forces to its nodes.
- minor vector view bugs removed.
- Elements as well as the model itself now have a asJSON() method, which returns a formatted JSON string. toJSON() will probably be removed in the future.
- view container added to model.
- vector view implemented.
- Bug removed in
mec.model.isActive
. The negated result was returned. (Changes in app required !) - Bug removed in
mec.model.hasActiveDrives
.
- Add
mec.load.spring
. - Remove hilite bug with
mec.load.force
. - Add
mec.gravity = {x:0,y:-10,active:false}
as default gravity vector and mode tomec.cor.js
. This is in order to switch gravity comfortable on and off, without affecting its vector. - Added a toJSON method to model and to all element types. model.toJSON() invokes .toJSON() on each element in the model returns a canonical JSON-representation of the model
- Implemented a global darkmode flag (default false) for darker canvas backgrounds. Most colors are now centralized as getters in mec.core.
- Added a different shading for elements when they are selected and not just hovered over.
- Rename
model.hasDependencies()
to the semantic more correctmodel.hasDependents()
. - Add
model.dependentsOf(elem)
to get a dictionary object of all dependents. - Add
model.purgeElements(elems)
to purge all elements in a dictionary object. - Add a new function
mec.toZero(a,eps)
tomec.core.js
. If amount ofa
is smaller thaneps
the result is0
elsea
. - Avoid constraint masses to get infinite.
- Rename
model.pos()
andmodel.vel()
tomodel.posStep()
andmodel.velStep()
. - Rename
constraint.pos()
andconstraint.vel()
toconstraint.posStep()
andconstraint.velStep()
. - Change
constraint.type
from object member to getter. - Eliminate ambiguity of
shape.bar
definition by defining{type:'bar',p1,p2}
and newshape.beam
by{type:'beam',p,wref,len}
- Split
mec.load
intomec.load
andmec.load.force
, to add other load types easier later.
- Adding a
static
type to drive functions, which is for velocity-less actuating positions. model.dirty
flag isn't used anymore. It's flagged asdepricated
.
- Commenting the requirement for
app
to provide acartesian
getter (seemec.microapp.js
) - Rename
tickTimer
'stick
method totimerTick
inmixin.js
to avoid collision withapp
's own newtick
method (should have no other side effects). - Rename
app.step
method toapp.tick
inmec.microapp.js
. - Adding
key
event handler tomec.microapp.js
for using escape key or others for anything. - Adding
state
toapp
to be compatible with Jan's (modifyingmec.microapp.js
when required). It has one of the values [created
,initialized
,active
,idle
,input
]. - Triggering new
app.pause
method when pressingEscape
key. - Accepting
mec.model.gravity
values as falsy, not necessarily of typeboolean
. - Throwing nodes by dragging, giving them an initial velocity, is deactivated at current. Has to be investigated further.
- When releasing the pointer after dragging, the node always has zero velocity.
- Implement
isSleeping
getter formodel
andnode
to indicate significant motion. - Automatically change
app.state
fromactive
toidle
inapp.tick()
, ifmodel.isSleeping === true
. - New
model.isActive
getter is testing, if there are any active drives in constraints or if some nodes are moving (see examplemec.5r.drive
) - drives with different start times are working now (see example
mec.somecranks
) - drives in constraints get additional boolean
bounce
property (see examplemec.crank
). - drives in constraints get additional integer
repeat
property (see examplemec.crank
).