This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createScene(renderer: WebGLRenderer) { | |
const scene = new Scene() | |
const camera = new PerspectiveCamera( | |
70, | |
window.innerWidth / window.innerHeight, | |
0.02, | |
20, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gltfLoader = new GLTFLoader(); | |
let carModel: Object3D; | |
gltfLoader.load("../assets/models/sports_car.glb", (gltf: GLTF) => { | |
carModel = gltf.scene.children[0]; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ambientLight = new AmbientLight(0xffffff, 1.0); | |
scene.add(ambientLight); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const controller = renderer.xr.getController(0); | |
scene.add(controller); | |
controller.addEventListener("select", onSelect); | |
function onSelect() { | |
if (planeMarker.visible) { | |
const model = carModel.clone(); | |
model.position.setFromMatrixPosition(planeMarker.matrix); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
classpath 'com.google.ar.sceneform:plugin:1.17.1' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.17.1' | |
implementation 'com.google.ar:core:1.27.0' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<uses-permission android:name="android.permission.CAMERA" /> | |
<uses-permission android:name="android.permission.INTERNET"/> | |
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/> | |
<application | |
...> | |
... | |
<meta-data | |
android:name="com.google.ar.core" | |
android:value="required" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
tools:context=".MainActivity"> | |
<fragment | |
android:id="@+id/ux_fragment" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private boolean checkIsSupportedDeviceOrFinish(final Activity activity) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { | |
Log.e(TAG, "Sceneform requires Android N or later"); | |
Toast.makeText(activity, "Sceneform requires Android N or later", Toast.LENGTH_LONG).show(); | |
activity.finish(); | |
return false; | |
} | |
String openGlVersionString = | |
((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)) | |
.getDeviceConfigurationInfo() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.google.ar.sceneform.plugin' |