オービットコントロールズ
説明
このコンポーネントを使用すると、エンティティの周りを制約で周回することができます。
プロパティ
プロパティ | タイプ | デフォルト | 説明 |
---|---|---|---|
speed | number | 5 | How fast the camera moves |
maxAngularSpeed | number | 10 | Max rotation speed of the camera |
maxZoomSpeed | number | 10 | Max zoom speed for the camera |
distanceMin | number | 5 | Minimum distance between the focused entity and the camera |
distanceMax | number | 20 | Maximum distance between the focused entity and the camera |
pitchAngleMin | number | -90 | Minimum pitch angle |
pitchAngleMax | number | 90 | Maximum pitch angle |
constrainYaw | boolean | false | Whether to constrain yaw |
yawAngleMin | number | 0 | Minimum yaw angle |
yawAngleMax | number | 0 | Maximum yaw angle |
inertiaFactor | number | 0.3 | Inertia factor for camera movement |
invertedX | boolean | false | Whether controls for moving on x-axis are inverted |
invertedY | boolean | false | Whether controls for moving on y-axis are inverted |
invertedZoom | boolean | false | Whether controls for zooming in and out are inverted |
controllerSupport | boolean | false | Whether to support controllers via the input-manager |
verticalSensitivity | number | 1 | Input sensitivity vertically |
horizontalSensitivity | number | 1 | Input sensitivity horizontally |
focusEntity | eid | undefined | Focus subject for the orbit camera |
機能
Get
Returns a read-only reference.
Example
ecs.OrbitControls.get(world, component.eid)
Set
Ensures the component exists on the entity, then assigns the (optional) data to the component.
Example
ecs.OrbitControls.set(world, component.eid, {
speed: 5,
maxAngularSpeed: 10,
maxZoomSpeed: 10,
distanceMin: 5,
distanceMax: 20,
pitchAngleMin: -90,
pitchAngleMax: 90,
constrainYaw: false,
yawAngleMin: 0,
yawAngleMax: 0,
inertiaFactor: 0.3,
invertedX: false,
invertedY: false,
invertedZoom: false,
controllerSupport: false,
verticalSensitivity: 1,
horizontalSensitivity: 1,
focusEntity: undefined
})
Mutate
Perform an update to the component within a callback function. Return true
to indicate no changes made.
Example
ecs.OrbitControls.mutate(world, component.eid, (cursor) => {
cursor.speed = 2;
cursor.maxAngularSpeed = 3;
return false;
})
Remove
Removes the component from the entity.
Example
ecs.OrbitControls.remove(world, component.eid)
Has
Returns true
if the component is present on the entity.
Example
ecs.OrbitControls.has(world, component.eid)
Reset
Adds, or resets the component to its default state.
Example
ecs.OrbitControls.reset(world, component.eid)
Advanced Functions
Cursor
Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.
Example
ecs.OrbitControls.cursor(world, component.eid)
Acquire
Same behavior as cursor, but commit must be called after the cursor is done being used.
Example
ecs.OrbitControls.acquire(world, component.eid)
Commit
Called after acquire. An optional third argument determines whether the cursor was mutated or not.
Example
ecs.OrbitControls.commit(world, component.eid)
ecs.OrbitControls.commit(world, component.eid, false)
Dirty
Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.
Example
ecs.OrbitControls.dirty(world, component.eid)