Difference between revisions of "R3d.World.new"

From GiderosMobile
 
(3 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
=== Description ===
 
=== Description ===
 
Creates a new ReactPhysics3D dynamics world.
 
Creates a new ReactPhysics3D dynamics world.
<source lang="lua">
+
<syntaxhighlight lang="lua">
r3d.World.new(gravityX, gravityY, gravityZ)
+
r3d.World.new(gravityX, gravityY, gravityZ,params)
</source>
+
</syntaxhighlight>
  
 
=== Parameters ===
 
=== Parameters ===
'''gravityX''': (number) the gravity on the X axis (m/s^2)<br/>
+
'''gravityX''': (number) the gravity on the X axis (m/s^2), ''default=0''<br/>
'''gravityY''': (number) the gravity on the Y axis (m/s^2)<br/>
+
'''gravityY''': (number) the gravity on the Y axis (m/s^2), ''default=-9.81''<br/>
'''gravityZ''': (number) the gravity on the Z axis (m/s^2)<br/>
+
'''gravityZ''': (number) the gravity on the Z axis (m/s^2), ''default=0''<br/>
 +
'''params''': (table) the world cutsom parameters, '''OPTIONAL & !EXPERIMENTAL!''', possible values are:<br/>
 +
* persistentContactDistanceThreshold, '''default=0.03'''
 +
* defaultFrictionCoefficient, '''default=0.3'''
 +
* defaultBounciness, '''default=0.5'''
 +
* restitutionVelocityThreshold, '''default=0.5'''
 +
* isSleepingEnabled, '''default=true'''
 +
* defaultVelocitySolverNbIterations, '''default=6'''
 +
* defaultPositionSolverNbIterations, '''default=3'''
 +
* defaultTimeBeforeSleep, '''default=1 (sec)'''
 +
* defaultSleepLinearVelocity, '''default=0.02'''
 +
* defaultSleepAngularVelocity, '''default=(3.0) * (PI_RP3D / (180.0))'''
 +
* cosAngleSimilarContactManifold, '''default=0.95'''
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "reactphysics3d"
 
require "reactphysics3d"
local world = r3d.World.new(0, -9.8, 0)
+
local world = r3d.World.new(0, -9.8, 0, {
</source>
+
isSleepingEnabled=false,
 +
defaultVelocitySolverNbIterations=20,
 +
})
 +
</syntaxhighlight>
  
 
{{R3d.World}}
 
{{R3d.World}}

Latest revision as of 01:13, 16 December 2025

Available since: Gideros 2019.10
Class: R3d.World

Description

Creates a new ReactPhysics3D dynamics world.

r3d.World.new(gravityX, gravityY, gravityZ,params)

Parameters

gravityX: (number) the gravity on the X axis (m/s^2), default=0
gravityY: (number) the gravity on the Y axis (m/s^2), default=-9.81
gravityZ: (number) the gravity on the Z axis (m/s^2), default=0
params: (table) the world cutsom parameters, OPTIONAL & !EXPERIMENTAL!, possible values are:

  • persistentContactDistanceThreshold, default=0.03
  • defaultFrictionCoefficient, default=0.3
  • defaultBounciness, default=0.5
  • restitutionVelocityThreshold, default=0.5
  • isSleepingEnabled, default=true
  • defaultVelocitySolverNbIterations, default=6
  • defaultPositionSolverNbIterations, default=3
  • defaultTimeBeforeSleep, default=1 (sec)
  • defaultSleepLinearVelocity, default=0.02
  • defaultSleepAngularVelocity, default=(3.0) * (PI_RP3D / (180.0))
  • cosAngleSimilarContactManifold, default=0.95

Example

require "reactphysics3d"
local world = r3d.World.new(0, -9.8, 0, {
	isSleepingEnabled=false,
	defaultVelocitySolverNbIterations=20,
})