Class: MSPhysics::CommonContext

Inherits:
Entity
  • Object
show all
Defined in:
RubyExtension/MSPhysics/common_context.rb

Overview

CommonContext contains methods that both BodyContext and ControllerContext objects have in common.

Since:

  • 1.0.0

Direct Known Subclasses

BodyContext, ControllerContext

Variables collapse

Instances collapse

Time collapse

User Input collapse

Functions collapse

Instance Method Summary collapse

Methods inherited from Entity

#inspect, #to_s

Constructor Details

#initializeCommonContext

Returns a new instance of CommonContext.

Since:

  • 1.0.0



15
16
17
# File 'RubyExtension/MSPhysics/common_context.rb', line 15

def initialize
  @_singular_repeater_flags = {}
end

Instance Method Details

#accumulator(rate, delay = 0.0) ⇒ Integer

Increment the accumulator by one at a specific rate and offset.

Examples:

Using in controller

accumulator(0.25, 2)

Parameters:

  • rate (Numeric)

    Accumulate every [rate] seconds.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Integer)

    The accumulator value

Since:

  • 1.0.0



460
461
462
463
# File 'RubyExtension/MSPhysics/common_context.rb', line 460

def accumulator(rate, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  (rtime > 0 && rate > MSPhysics::EPSILON) ? (rtime / rate).to_i : 0
end

#delete_global_var(name) ⇒ Boolean

Remove global variable from hash.

Parameters:

  • name (String, Symbol)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



126
127
128
# File 'RubyExtension/MSPhysics/common_context.rb', line 126

def delete_global_var(name)
  @@_global_variables.delete(name) != nil
end

#delete_var(name) ⇒ Boolean

Remove variable from hash.

Parameters:

  • name (String, Symbol)

Returns:

  • (Boolean)

    success

Since:

  • 1.0.0



69
70
71
# File 'RubyExtension/MSPhysics/common_context.rb', line 69

def delete_var(name)
  @@_variables.delete(name) != nil
end

#frameInteger

Get simulation frame.

Examples:

Using in controller

(frame > 100) ? 1 : 0

Returns:

  • (Integer)

Since:

  • 1.0.0



154
155
156
# File 'RubyExtension/MSPhysics/common_context.rb', line 154

def frame
  MSPhysics::Simulation.instance.frame
end

#get_global_var(name) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist throughout the session of the SketchUp process. They are preserved after simulation ends.

Get global variable value.

Parameters:

  • name (String, Symbol)

Returns:

  • (Object)

    Variable value or nil if variable with the specified name doesn’t exist.

Since:

  • 1.0.0



94
95
96
# File 'RubyExtension/MSPhysics/common_context.rb', line 94

def get_global_var(name)
  @@_global_variables[name]
end

#get_set_global_var(name, value) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist throughout the session of the SketchUp process. They are preserved after simulation ends.

Get original global variable value and assign a new value.

Parameters:

  • name (String, Symbol)
  • value (Object)

Returns:

  • (Object)

    Original value or nil if originally the variable didn’t exist.

Since:

  • 1.0.0



117
118
119
120
121
# File 'RubyExtension/MSPhysics/common_context.rb', line 117

def get_set_global_var(name, value)
  orig_value = @@_global_variables[name]
  @@_global_variables[name] = value
  orig_value
end

#get_set_var(name, value) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist only throughout the session of simulation. They are disposed of after simulation ends.

Get original variable value and assign a new value.

Parameters:

  • name (String, Symbol)
  • value (Object)

Returns:

  • (Object)

    Original value or nil if originally the variable didn’t exist.

Since:

  • 1.0.0



81
82
83
84
85
# File 'RubyExtension/MSPhysics/common_context.rb', line 81

def get_set_var(name, value)
  orig_value = @@_variables[name]
  @@_variables[name] = value
  orig_value
end

#get_var(name) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist only throughout the session of simulation. They are disposed of after simulation ends.

Get variable value.

Examples:

Joint controller based on a script

# The following is pasted to one of the script tabs
onStart {
  set_var('angle', 0.0) # This variable is accessible across all script and controller contexts.
  @step = 0.2 # This variable is accessible within this script context only.
}
onTick {
  cur_angle = get_var('angle') # Local variable accessible within a block.
  # Control angle with keys g and r, that is within the boundaries -30 and 12 degrees.
  if key('r') == 1 && cur_angle < 12.0
    cur_angle += @step
  elsif key('g') == 1 && cur_angle > -30.0
    cur_angle -= @step
  end
  # Clamp the angle value to ensure its within range
  cur_angle = AMS.clamp(cur_angle, -30.0, 12.0)
  # Assign new value to the 'angle' variable
  set_var('angle', cur_angle)
}

# The following is pasted to one or more of the joint controllers
get_var('angle')

Parameters:

  • name (String, Symbol)

Returns:

  • (Object)

    Variable value or nil if variable with the specified name doesn’t exist.

Since:

  • 1.0.0



50
51
52
# File 'RubyExtension/MSPhysics/common_context.rb', line 50

def get_var(name)
  @@_variables[name]
end

#joybutton(button) ⇒ Integer

Note:

Button name parameter is not case sensitive.

Get joy-button value.

Examples:

onUpdate {
  value = joybutton(:lt)
  simulation.display_note value.to_s
}

Parameters:

  • button (String, Symbol)

    Button name. Valid names are:

    • A : The A button.

    • B : The B button.

    • X : The X button.

    • Y : The Y button.

    • LB : The left shoulder button, above the trigger.

    • RB : The right shoulder button, above the trigger.

    • LT : The left trigger.

    • RT : The right trigger.

    • back : The back button.

    • start : The start button.

    • leftb : The left thumbstick button.

    • rightb : The right thumbstick button.

Returns:

  • (Integer)

    1 if the button is down; 0 if the button is up.

Since:

  • 1.0.0



294
295
296
297
# File 'RubyExtension/MSPhysics/common_context.rb', line 294

def joybutton(button)
  v = MSPhysics::Simulation.instance.joybutton_data[button.to_s.downcase]
  v ? v : 0
end

#joypadInteger

Get joy-pad value.

  • 0 if hat is centered

  • 1 if hat is up

  • 2 if hat is right

  • 4 if hat is down

  • 8 if hat is left

  • 12 if hat is left-down

  • 9 if hat is left-up

  • 6 if hat is right-down

  • 3 if hat is right-up

Examples:

onUpdate {
  value = joypad()
  simulation.display_note value.to_s
}

Returns:

  • (Integer)

    Returns one of the following values:

Since:

  • 1.0.0



315
316
317
# File 'RubyExtension/MSPhysics/common_context.rb', line 315

def joypad
  MSPhysics::Simulation.instance.joypad_data
end

#joystick(axis) ⇒ Numeric

Note:

Axis name parameter is not case sensitive.

Get joystick value.

Examples:

onUpdate {
  value = joystick(:leftx)
  simulation.display_note value.to_s
}

Parameters:

  • axis (String, Symbol)

    Axis name. Valid names are:

    • 'leftx' : X-XAXIS position on left thumbstick.

    • 'lefty' : Y-XAXIS position on left thumbstick.

    • 'leftz' : Left trigger position.

    • 'rightx' : X-XAXIS position on right thumbstick.

    • 'righty' : Y-XAXIS position on right thumbstick.

    • 'rightz' : Right trigger position.

Returns:

  • (Numeric)

    Stick position on the axis, a ranging value from -1.0 to 1.0.

Since:

  • 1.0.0



268
269
270
271
# File 'RubyExtension/MSPhysics/common_context.rb', line 268

def joystick(axis)
  v = MSPhysics::Simulation.instance.joystick_data[axis.to_s.downcase]
  v ? v : 0.0
end

#key(vk) ⇒ Integer

Note:

The vk parameter is not case sensitive.

Get state of a keyboard key.

Examples:

Using in controller

key('space') * 10

Parameters:

  • vk (String, Symbol, Integer)

    Virtual key code or name.

Returns:

  • (Integer)

    1 if down, 0 if up.

See Also:

Since:

  • 1.0.0



169
170
171
172
# File 'RubyExtension/MSPhysics/common_context.rb', line 169

def key(vk)
  return 0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  AMS::Keyboard.key(vk)
end

#key_slider(name, key1, key2, default_value = 0.0, min = 0.0, max = 1.0, step = 1.0) ⇒ Numeric

Create a new range slider or get slider value if slider with the specified name already exists.

Examples:

Using in controller

key_slider('Lift', 'up', 'down', 0, -4, 26, 5)

Parameters:

  • name (String)

    Slider name.

  • key1 (String)

    The positive directing key.

  • key2 (String)

    The negative directing key.

  • default_value (Numeric) (defaults to: 0.0)

    Starting value.

  • min (Numeric) (defaults to: 0.0)

    Minimum value.

  • max (Numeric) (defaults to: 1.0)

    Maximum value.

  • step (Numeric) (defaults to: 1.0)

    Accumulation step in units per second.

Returns:

  • (Numeric)

    Slider value.

See Also:

Since:

  • 1.0.0



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'RubyExtension/MSPhysics/common_context.rb', line 237

def key_slider(name, key1, key2, default_value = 0.0, min = 0.0, max = 1.0, step = 1.0)
  data = @@_key_sliders[name]
  unless data
    data = {
      :key1 => key1,
      :key2 => key2,
      :value => default_value.to_f,
      :min => min.to_f,
      :max => max.to_f,
      :step => step.to_f
    }
    @@_key_sliders[name] = data
  end
  data[:value]
end

#leftxNumeric

Output from keys D and A or X-axis position on the left joystick.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



355
356
357
358
359
360
361
# File 'RubyExtension/MSPhysics/common_context.rb', line 355

def leftx
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('d') - AMS::Keyboard.key('a')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['leftx']
  v ? v : 0.0
end

#leftyNumeric

Output from keys W and S or Y-axis position on the left joystick.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



365
366
367
368
369
370
371
# File 'RubyExtension/MSPhysics/common_context.rb', line 365

def lefty
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('w') - AMS::Keyboard.key('s')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['lefty']
  v ? v : 0.0
end

#leftzNumeric

Output from keys E and Q or position of the joy controller’s left trigger.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



375
376
377
378
379
380
381
# File 'RubyExtension/MSPhysics/common_context.rb', line 375

def leftz
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('e') - AMS::Keyboard.key('q')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['leftz']
  v ? v : 0.0
end

#numxInteger

Output from keys NUMPAD6 and NUMPAD4 or centered-X-axis position on the joy-pad.

Returns:

  • (Integer)

    -1, 0, or 1.

Since:

  • 1.0.0



386
387
388
389
390
391
392
# File 'RubyExtension/MSPhysics/common_context.rb', line 386

def numx
  return 0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('numpad6') - AMS::Keyboard.key('numpad4')
  return v if v != 0
  jpd = MSPhysics::Simulation.instance.joypad_data
  jpd == 2 ? 1 : (jpd == 8 ? -1 : 0)
end

#numyInteger

Output from keys NUMPAD8 and NUMPAD5 or centered-Y-axis position on the joy-pad.

Returns:

  • (Integer)

    -1, 0, or 1.

Since:

  • 1.0.0



397
398
399
400
401
402
403
# File 'RubyExtension/MSPhysics/common_context.rb', line 397

def numy
  return 0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('numpad8') - AMS::Keyboard.key('numpad5')
  return v if v != 0
  jpd = MSPhysics::Simulation.instance.joypad_data
  jpd == 1 ? 1 : (jpd == 4 ? -1 : 0)
end

#oscillator(frequency, delay = 0.0) ⇒ Numeric

Calculate the value of a sine curve at a particular world time.

Examples:

Using in controller

oscillator(0.8) * 4

Parameters:

  • frequency (Numeric)

    Number of times to oscillate per second.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



414
415
416
417
418
419
# File 'RubyExtension/MSPhysics/common_context.rb', line 414

def oscillator(frequency, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  return 0.0 if rtime < 0
  inc = frequency * 2 * Math::PI
  Math.sin(inc * rtime)
end

#oscillator2(frequency, delay = 0.0) ⇒ Numeric

Compute the value of a shifted sine curve at a particular world time.

Parameters:

  • frequency (Numeric)

    Number of times to oscillate per second.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Numeric)

    A value ranging from 0.0 to 1.0.

Since:

  • 1.0.0



437
438
439
440
441
# File 'RubyExtension/MSPhysics/common_context.rb', line 437

def oscillator2(frequency, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  return 0.0 if rtime < 0
  Math.sin(2 * Math::PI * (frequency * rtime - 0.25)) * 0.5 + 0.5
end

#oscillator2_slope(frequency, delay = 0.0) ⇒ Numeric

Calculate the slope of a shifted sine curve at a particular world time.

Parameters:

  • frequency (Numeric)

    Number of times to oscillate per second.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Numeric)

    A value ranging from -πf to πf, where f is the frequency.

Since:

  • 1.0.0



448
449
450
451
452
# File 'RubyExtension/MSPhysics/common_context.rb', line 448

def oscillator2_slope(frequency, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  return 0.0 if rtime < 0
  frequency * Math::PI * Math.cos(2 * Math::PI * (frequency * rtime - 0.25))
end

#oscillator_slope(frequency, delay = 0.0) ⇒ Numeric

Calculate the slope of a sine curve at a particular world time.

Parameters:

  • frequency (Numeric)

    Number of times to oscillate per second.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Numeric)

    A value ranging from -2πf to 2πf, where f is the frequency.

Since:

  • 1.0.0



426
427
428
429
430
431
# File 'RubyExtension/MSPhysics/common_context.rb', line 426

def oscillator_slope(frequency, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  return 0.0 if rtime < 0
  inc = frequency * 2 * Math::PI
  inc * Math.cos(inc * rtime)
end

#repeater(rate, hold, delay = 0.0) ⇒ Integer

Compute a repeater value based on rate, hold, and delay.

Examples:

Using in controller

repeater(1, 0.4, 0)

Parameters:

  • rate (Numeric)

    Repeat every [rate] seconds.

  • hold (Numeric)

    The time, in seconds, to hold the repeater turned on whenever it is triggered.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

Returns:

  • (Integer)

    1 or 0

Since:

  • 1.0.0



473
474
475
476
# File 'RubyExtension/MSPhysics/common_context.rb', line 473

def repeater(rate, hold, delay = 0.0)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  (rtime > 0 && rate > MSPhysics::EPSILON && rtime % rate < hold) ? 1 : 0
end

#rightxNumeric

Output from LEFT and RIGHT arrow keys or X-axis position on the right joystick.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



322
323
324
325
326
327
328
# File 'RubyExtension/MSPhysics/common_context.rb', line 322

def rightx
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('right') - AMS::Keyboard.key('left')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['rightx']
  v ? v : 0.0
end

#rightyNumeric

Output from UP and DOWN arrow keys or Y-axis position on the right joystick.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



333
334
335
336
337
338
339
# File 'RubyExtension/MSPhysics/common_context.rb', line 333

def righty
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('up') - AMS::Keyboard.key('down')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['righty']
  v ? v : 0.0
end

#rightzNumeric

Output from keys PageUp and PageDown or position of the joy controller’s right trigger.

Returns:

  • (Numeric)

    A value ranging from -1.0 to 1.0.

Since:

  • 1.0.0



344
345
346
347
348
349
350
# File 'RubyExtension/MSPhysics/common_context.rb', line 344

def rightz
  return 0.0 if AMS::IS_PLATFORM_WINDOWS && !AMS::Sketchup.is_main_window_active?
  v = AMS::Keyboard.key('PageUp') - AMS::Keyboard.key('PageDown')
  return v.to_f if v != 0
  v = MSPhysics::Simulation.instance.joystick_data['rightz']
  v ? v : 0.0
end

#set_global_var(name, value) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist throughout the session of the SketchUp process. They are preserved after simulation ends.

Set global variable value.

Parameters:

  • name (String, Symbol)
  • value (Object)

Returns:

  • (Object)

    The newly assigned value.

Since:

  • 1.0.0



105
106
107
# File 'RubyExtension/MSPhysics/common_context.rb', line 105

def set_global_var(name, value)
  @@_global_variables[name] = value
end

#set_var(name, value) ⇒ Object

Note:

These variables are accessible in all body/controller scopes and exist only throughout the session of simulation. They are disposed of after simulation ends.

Set variable value.

Examples:

Joint controller based on a script

# The following is pasted to one of the script tabs
onStart {
  set_var('angle', 0.0) # This variable is accessible across all script and controller contexts.
  @step = 0.2 # This variable is accessible within this script context only.
}
onTick {
  cur_angle = get_var('angle') # Local variable accessible within a block.
  # Control angle with keys g and r, that is within the boundaries -30 and 12 degrees.
  if key('r') == 1 && cur_angle < 12.0
    cur_angle += @step
  elsif key('g') == 1 && cur_angle > -30.0
    cur_angle -= @step
  end
  # Clamp the angle value to ensure its within range
  cur_angle = AMS.clamp(cur_angle, -30.0, 12.0)
  # Assign new value to the 'angle' variable
  set_var('angle', cur_angle)
}

# The following is pasted to one or more of the joint controllers
get_var('angle')

Parameters:

  • name (String, Symbol)
  • value (Object)

Returns:

  • (Object)

    The newly assigned value.

Since:

  • 1.0.0



62
63
64
# File 'RubyExtension/MSPhysics/common_context.rb', line 62

def set_var(name, value)
  @@_variables[name] = value
end

#simulationSimulation

Get Simulation instance.

Returns:

Since:

  • 1.0.0



135
136
137
# File 'RubyExtension/MSPhysics/common_context.rb', line 135

def simulation
  MSPhysics::Simulation.instance
end

#singular_repeater(rate, delay = 0.0, id = nil) ⇒ Integer

Compute a repeater value based on rate and delay that repeats only one time whenever it is triggered.

Examples:

Output frame every 0.25 seconds.

onTick {
  if singular_repeater(0.25) == 1
    puts frame
  end
}

Parameters:

  • rate (Numeric)

    Repeat every [rate] seconds.

  • delay (Numeric) (defaults to: 0.0)

    The time to wait, in seconds, before starting.

  • id (Object) (defaults to: nil)

    Unique repeat identifier.

Returns:

  • (Integer)

    1 or 0

Since:

  • 1.0.0



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'RubyExtension/MSPhysics/common_context.rb', line 490

def singular_repeater(rate, delay = 0.0, id = nil)
  rtime = MSPhysics::Simulation.instance.world.time - delay
  if rtime > 0 && rate > MSPhysics::EPSILON
    res = (rtime / rate).to_i
    opts = [rate, delay, id]
    if @_singular_repeater_flags[opts] == res
      return 0
    else
      @_singular_repeater_flags[opts] = res
      return 1
    end
  else
    return 0
  end
end

#slider(name, default_value = 0.0, min = 0.0, max = 1.0, step = 1.0) ⇒ Numeric

Create a new range slider or get slider value if slider with the specified name already exists.

Examples:

Using in controller

slider('Rotate', 0, -10, 10, 0.01)

Parameters:

  • name (String)

    Slider name.

  • default_value (Numeric) (defaults to: 0.0)

    Starting value.

  • min (Numeric) (defaults to: 0.0)

    Minimum value.

  • max (Numeric) (defaults to: 1.0)

    Maximum value.

  • step (Numeric) (defaults to: 1.0)

    Snap step.

Returns:

  • (Numeric)

    Slider value.

Since:

  • 1.0.0



215
216
217
218
219
220
221
222
# File 'RubyExtension/MSPhysics/common_context.rb', line 215

def slider(name, default_value = 0.0, min = 0.0, max = 1.0, step = 1.0)
  unless MSPhysics::ControlPanel.slider_exists?(name)
    MSPhysics::ControlPanel.open
    MSPhysics::ControlPanel.show
    MSPhysics::ControlPanel.add_slider(name, default_value, min, max, step)
  end
  MSPhysics::ControlPanel.get_slider_value(name)
end

#toggle_key(vk) ⇒ Integer

Note:

The vk parameter is not case sensitive.

Get toggled state of a keyboard key.

Examples:

Using in controller

toggle_key('space') * 10

Parameters:

  • vk (String, Symbol, Integer)

    Virtual key code or name.

Returns:

  • (Integer)

    1 if toggled down, 0 if toggled up.

See Also:

Since:

  • 1.0.0



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'RubyExtension/MSPhysics/common_context.rb', line 182

def toggle_key(vk)
  vkc = AMS::Keyboard.get_key_code(vk)
  vks = AMS::Keyboard.key_down?(vkc)
  vkt = @@_toggled[vkc] || 0
  if vkt == 0 && vks
    @@_toggled[vkc] = 1
    1
  elsif (vkt == 1 && vks) || (vkt == 2 && !vks)
    1
  elsif vkt == 1 && !vks
    @@_toggled[vkc] = 2
    1
  elsif vkt == 2 && vks
    @@_toggled[vkc] = 3
    0
  elsif vkt == 3 && !vks
    @@_toggled[vkc] = 0
    0
  else
    0
  end
end

#worldWorld

Get simulation World instance.

Examples:

Using in controller

(world.time > 4) ? 1 : 0

Returns:

Since:

  • 1.0.0



143
144
145
# File 'RubyExtension/MSPhysics/common_context.rb', line 143

def world
  MSPhysics::Simulation.instance.world
end