Skip to content

Commit

Permalink
Rename the extension Scene3D and the object Cube3DObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Davy Hélard committed Apr 27, 2023
1 parent 957e863 commit f1300d6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace gdjs {
/** Base parameters for {@link gdjs.ThreeDShapeRuntimeObject} */
export interface ThreeDShapeObjectData extends ObjectData {
/** Base parameters for {@link gdjs.Cube3DRuntimeObject} */
export interface Cube3DObjectData extends ObjectData {
/** The base parameters of the ThreeDShape */
content: {
width: float;
Expand Down Expand Up @@ -34,8 +34,8 @@ namespace gdjs {
/**
* Shows a 3D box object.
*/
export class ThreeDShapeRuntimeObject extends gdjs.RuntimeObject {
_renderer: ThreeDShapeRuntimeObjectRenderer;
export class Cube3DRuntimeObject extends gdjs.RuntimeObject {
_renderer: Cube3DRuntimeObjectRenderer;
private _z: float = 0;
private _width: float;
private _height: float;
Expand All @@ -55,7 +55,7 @@ namespace gdjs {

constructor(
instanceContainer: gdjs.RuntimeInstanceContainer,
objectData: ThreeDShapeObjectData
objectData: Cube3DObjectData
) {
super(instanceContainer, objectData);

Expand Down Expand Up @@ -84,7 +84,7 @@ namespace gdjs {
objectData.content.bottomFaceResourceName,
];

this._renderer = new gdjs.ThreeDShapeRuntimeObjectRenderer(
this._renderer = new gdjs.Cube3DRuntimeObjectRenderer(
this,
instanceContainer
);
Expand Down Expand Up @@ -157,8 +157,8 @@ namespace gdjs {
}

updateFromObjectData(
oldObjectData: ThreeDShapeObjectData,
newObjectData: ThreeDShapeObjectData
oldObjectData: Cube3DObjectData,
newObjectData: Cube3DObjectData
): boolean {
if (oldObjectData.content.width !== newObjectData.content.width) {
this.setWidth(newObjectData.content.width);
Expand Down Expand Up @@ -386,5 +386,5 @@ namespace gdjs {
this._renderer.updateSize();
}
}
gdjs.registerObject('3D::ThreeDShapeObject', gdjs.ThreeDShapeRuntimeObject);
gdjs.registerObject('Scene3D::Cube3DObject', gdjs.Cube3DRuntimeObject);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ namespace gdjs {
return transparentMaterial;
};

class ThreeDShapeRuntimeObjectPixiRenderer {
private _object: gdjs.ThreeDShapeRuntimeObject;
class Cube3DRuntimeObjectPixiRenderer {
private _object: gdjs.Cube3DRuntimeObject;
private _runtimeGame: gdjs.RuntimeGame;
private _boxMesh: THREE.Mesh;

constructor(
runtimeObject: gdjs.ThreeDShapeRuntimeObject,
runtimeObject: gdjs.Cube3DRuntimeObject,
instanceContainer: gdjs.RuntimeInstanceContainer
) {
this._object = runtimeObject;
Expand Down Expand Up @@ -119,6 +119,6 @@ namespace gdjs {
}
}

export const ThreeDShapeRuntimeObjectRenderer = ThreeDShapeRuntimeObjectPixiRenderer;
export type ThreeDShapeRuntimeObjectRenderer = ThreeDShapeRuntimeObjectPixiRenderer;
export const Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;
export type Cube3DRuntimeObjectRenderer = Cube3DRuntimeObjectPixiRenderer;
}
84 changes: 42 additions & 42 deletions Extensions/3D/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ module.exports = {
const extension = new gd.PlatformExtension();
extension
.setExtensionInformation(
'3D',
'Scene3D',
_('3D'),
_('Support for 3D in GDevelop.'),
'Florian Rival',
'MIT'
)
.setCategory('General');

const threeDShapeObject = new gd.ObjectJsImplementation();
const Cube3DObject = new gd.ObjectJsImplementation();
// $FlowExpectedError - ignore Flow warning as we're creating an object
threeDShapeObject.updateProperty = function (
Cube3DObject.updateProperty = function (
objectContent,
propertyName,
newValue
Expand Down Expand Up @@ -76,7 +76,7 @@ module.exports = {
return false;
};
// $FlowExpectedError - ignore Flow warning as we're creating an object
threeDShapeObject.getProperties = function (objectContent) {
Cube3DObject.getProperties = function (objectContent) {
const objectProperties = new gd.MapStringPropertyDescriptor();

objectProperties
Expand Down Expand Up @@ -195,7 +195,7 @@ module.exports = {

return objectProperties;
};
threeDShapeObject.setRawJSONContent(
Cube3DObject.setRawJSONContent(
JSON.stringify({
width: 100,
height: 100,
Expand All @@ -216,7 +216,7 @@ module.exports = {
);

// $FlowExpectedError
threeDShapeObject.updateInitialInstanceProperty = function (
Cube3DObject.updateInitialInstanceProperty = function (
objectContent,
instance,
propertyName,
Expand All @@ -242,7 +242,7 @@ module.exports = {
};

// $FlowExpectedError
threeDShapeObject.getInitialInstanceProperties = function (
Cube3DObject.getInitialInstanceProperties = function (
content,
instance,
project,
Expand Down Expand Up @@ -273,18 +273,18 @@ module.exports = {

const object = extension
.addObject(
'ThreeDShapeObject',
'Cube3DObject',
_('3D Shape'),
_('A 3D shape.'),
'JsPlatform/Extensions/3d_box.svg',
threeDShapeObject
Cube3DObject
)
.setCategoryFullName(_('3D'))
.addUnsupportedBaseObjectCapability('effect')
// .addUnsupportedBaseObjectCapability('effect') // TODO: are there more unsupported features?
.setIncludeFile('Extensions/3D/threedshaperuntimeobject.js')
.setIncludeFile('Extensions/3D/Cube3DRuntimeObject.js')
.addIncludeFile(
'Extensions/3D/threedshaperuntimeobject-pixi-renderer.js'
'Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js'
);

// Properties expressions/conditions/actions:
Expand All @@ -298,7 +298,7 @@ module.exports = {
'',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setZ')
.setGetter('getZ');
Expand All @@ -313,7 +313,7 @@ module.exports = {
'',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setDepth')
.setGetter('getDepth');
Expand All @@ -328,7 +328,7 @@ module.exports = {
'',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setRotationX')
.setGetter('getRotationX');
Expand All @@ -343,7 +343,7 @@ module.exports = {
'',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setRotationY')
.setGetter('getRotationY');
Expand All @@ -358,7 +358,7 @@ module.exports = {
'',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.addParameter(
'stringWithSelector',
_('Face'),
Expand All @@ -382,7 +382,7 @@ module.exports = {
'res/conditions/3d_box.svg',
'res/conditions/3d_box.svg'
)
.addParameter('object', _('3D Shape'), 'ThreeDShapeObject', false)
.addParameter('object', _('3D Shape'), 'Cube3DObject', false)
.addParameter(
'stringWithSelector',
_('Face'),
Expand All @@ -409,9 +409,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setCameraZ')
.setGetter('gdjs.threeD.camera.getCameraZ')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setCameraZ')
.setGetter('gdjs.scene3d.camera.getCameraZ')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addExpressionAndConditionAndAction(
Expand All @@ -435,9 +435,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setCameraRotationX')
.setGetter('gdjs.threeD.camera.getCameraRotationX')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setCameraRotationX')
.setGetter('gdjs.scene3d.camera.getCameraRotationX')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addExpressionAndConditionAndAction(
Expand All @@ -461,9 +461,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setCameraRotationY')
.setGetter('gdjs.threeD.camera.getCameraRotationY')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setCameraRotationY')
.setGetter('gdjs.scene3d.camera.getCameraRotationY')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addAction(
Expand All @@ -477,15 +477,15 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addCodeOnlyParameter('currentScene', '')
.addParameter('objectPtr', _('Object'), '3D::ThreeDShapeObject')
.addParameter('objectPtr', _('Object'), 'Scene3D::Cube3DObject')
.addParameter('layer', _('Layer'), '', true)
.setDefaultValue('""')
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.addParameter('yesorno', _('Stand on Y instead of Z'), '', true)
.setDefaultValue('false')
.setFunctionName('gdjs.threeD.camera.turnCameraTowardObject')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.turnCameraTowardObject')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addAction(
Expand All @@ -508,8 +508,8 @@ module.exports = {
.setDefaultValue('0')
.addParameter('yesorno', _('Stand on Y instead of Z'), '', true)
.setDefaultValue('false')
.setFunctionName('gdjs.threeD.camera.turnCameraTowardPosition')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.turnCameraTowardPosition')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addExpressionAndConditionAndAction(
Expand All @@ -531,9 +531,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setNearPlane')
.setGetter('gdjs.threeD.camera.getNearPlane')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setNearPlane')
.setGetter('gdjs.scene3d.camera.getNearPlane')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addExpressionAndConditionAndAction(
Expand All @@ -555,9 +555,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setFarPlane')
.setGetter('gdjs.threeD.camera.getFarPlane')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setFarPlane')
.setGetter('gdjs.scene3d.camera.getFarPlane')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

extension
.addExpressionAndConditionAndAction(
Expand All @@ -581,9 +581,9 @@ module.exports = {
.addParameter('expression', _('Camera number (default : 0)'), '', true)
.setDefaultValue('0')
.markAsAdvanced()
.setFunctionName('gdjs.threeD.camera.setFov')
.setGetter('gdjs.threeD.camera.getFov')
.setIncludeFile('Extensions/3D/threedtools.js');
.setFunctionName('gdjs.scene3d.camera.setFov')
.setGetter('gdjs.scene3d.camera.getFov')
.setIncludeFile('Extensions/3D/Scene3DTools.js');

return extension;
},
Expand Down Expand Up @@ -612,7 +612,7 @@ module.exports = {
objectsEditorService /*: ObjectsEditorService */
) {
objectsEditorService.registerEditorConfiguration(
'3D::ThreeDShapeObject',
'Scene3D::Cube3DObject',
objectsEditorService.getDefaultObjectJsImplementationPropertiesEditor({
helpPagePath: '/objects/3d_shape',
})
Expand Down Expand Up @@ -848,7 +848,7 @@ module.exports = {
}

objectsRenderingService.registerInstanceRenderer(
'3D::ThreeDShapeObject',
'Scene3D::Cube3DObject',
RenderedThreeDShapeObjectInstance
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace gdjs {
export namespace threeD {
export namespace scene3d {
const assumedFovIn2D = 45;

export namespace camera {
Expand Down Expand Up @@ -106,7 +106,7 @@ namespace gdjs {

export const turnCameraTowardObject = (
runtimeScene: RuntimeScene,
object: gdjs.ThreeDShapeRuntimeObject,
object: gdjs.Cube3DRuntimeObject,
layerName: string,
cameraIndex: integer,
isStandingOnY: boolean
Expand Down

0 comments on commit f1300d6

Please sign in to comment.