Skip to content

Instantly share code, notes, and snippets.

View codemaker2015's full-sized avatar
:octocat:
Designing, Developing and Deploying

Vishnu Sivan codemaker2015

:octocat:
Designing, Developing and Deploying
View GitHub Profile
@codemaker2015
codemaker2015 / scene.ts
Last active March 20, 2022 13:30
createScene() method updated with hitTest
export function createScene(renderer: WebGLRenderer) {
const scene = new Scene()
const camera = new PerspectiveCamera(
70,
window.innerWidth / window.innerHeight,
0.02,
20,
)
@codemaker2015
codemaker2015 / scene.ts
Created March 20, 2022 13:40
load the gltf model
const gltfLoader = new GLTFLoader();
let carModel: Object3D;
gltfLoader.load("../assets/models/sports_car.glb", (gltf: GLTF) => {
carModel = gltf.scene.children[0];
});
@codemaker2015
codemaker2015 / scene.ts
Created March 20, 2022 13:50
Add lighting
const ambientLight = new AmbientLight(0xffffff, 1.0);
scene.add(ambientLight);
@codemaker2015
codemaker2015 / scene.ts
Last active March 20, 2022 14:04
Adding a WebXR Controller
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);
@codemaker2015
codemaker2015 / build.gradle
Created April 13, 2022 04:14
sceneform dependency
dependencies {
...
classpath 'com.google.ar.sceneform:plugin:1.17.1'
}
@codemaker2015
codemaker2015 / build.gradle
Last active April 13, 2022 04:16
sceneform dependency
dependencies {
...
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.17.1'
implementation 'com.google.ar:core:1.27.0'
}
@codemaker2015
codemaker2015 / AndroidManifest.xml
Last active April 13, 2022 04:26
arcore permissions
<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" />
@codemaker2015
codemaker2015 / activity_main.xml
Created April 13, 2022 04:32
ar fragment layout
<?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"
@codemaker2015
codemaker2015 / MainActivity.java
Last active April 13, 2022 04:35
compatibility check
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()
@codemaker2015
codemaker2015 / build.gradle
Created April 13, 2022 04:45
plugin dependency
apply plugin: 'com.google.ar.sceneform.plugin'