Skip to content

Reducing the scale of a 3D model changes its position #6

Open
@tjvantoll

Description

@tjvantoll

Which platform(s) does your issue occur on?

iOS. Tested on iPhone 6S and an iPad Pro.

Please, provide the following version numbers that your issue occurs with:

  • CLI: 3.4.0
  • Cross-platform modules: 3.4.0
  • Runtime(s): 3.4.0
  • Plugin(s): nativescript-ar version 0.3.2

Please, tell us how to recreate the issue in as much detail as possible.

This one is a bit complex to explain. It happens when using this plugin’s addModel() function and setting both the scale and position properties. If you set the scale, the position at which the resized model is placed at does not take into account the new size.

For testing I’ve been using the Car.dae model in this repo’s demo app. To see this behavior in action, change the planeTapped() function in the demo’s main-page.ts file to do the following.

const ar: AR = args.object;
ar.addModel({
  name: "Models.scnassets/Car.dae",
  position: {
    x: args.position.x,
    y: args.position.y,
    z: args.position.z
  },
  scale: 0.1,
  mass: 20
});

Expected behavior: The car model appears exactly where you tap, as you set the position to the exact x/y/z coordinates of the plane tap.

Actual behavior: The car model floats above the plane, presumably because positioning occurs relative to the non-resized version of the model.

I took a stab at getting the car on the plane without hardcoding random adjustments to the positioning coordinates... and I failed. The problem is I don’t know the dimensions of the model itself, so I don’t the numbers I need to do the math against.

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions