Skip to content

Commit 9cadf43

Browse files
authored
Camera and orbit controls information (#28)
1 parent 82d4b99 commit 9cadf43

File tree

11 files changed

+47
-26
lines changed

11 files changed

+47
-26
lines changed

doc/Blazor3D.xml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet/Blazor3D/Blazor3D/Settings/WebGLRendererSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
public class WebGLRendererSettings
77
{
88
/// <summary>
9-
/// Whether to perform antialiasing. Default is false.
9+
/// Whether to perform antialiasing. Default is true.
1010
/// </summary>
11-
public bool Antialias { get; set; } = false;
11+
public bool Antialias { get; set; } = true;
1212
}
1313
}

src/dotnet/Blazor3D/Blazor3D/Viewers/Viewer.razor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Newtonsoft.Json;
88
using Blazor3D.Maths;
99
using Blazor3D.Objects;
10-
using Blazor3D.Enums;
1110
using Blazor3D.Lights;
1211
using Blazor3D.ComponentHelpers;
1312
using Blazor3D.Events;
@@ -133,6 +132,15 @@ public async Task UpdateCamera(Camera camera)
133132
await bundleModule.InvokeVoidAsync("updateCamera", json);
134133
}
135134

135+
/// <summary>
136+
/// Prints information about current camera and orbit controls into browser console.
137+
/// </summary>
138+
/// <returns>Task</returns>
139+
public async Task ShowCurrentCameraInfo()
140+
{
141+
await bundleModule.InvokeVoidAsync("showCurrentCameraInfo");
142+
}
143+
136144
[JSInvokable]
137145
public static Task<string> ReceiveSelectedObjectUUID(string containerId, string uuid)
138146
{

src/dotnet/Blazor3D/Blazor3D/wwwroot/js/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dotnet/Blazor3D/TestServer/Pages/Page2.razor

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<button @onclick="OnLoadObjButtonClick">Load OBJ</button>
2323
<button @onclick="OnClearAllClick">ClearAll</button>
2424
<button @onclick="OnClearLast">RemoveLast</button>
25+
<button @onclick="OnShowCameraInfo">ShowCameraInfo</button>
2526
</div>
2627
<div>@selectionMsg</div>
2728
</div>
@@ -78,12 +79,12 @@
7879

7980
private async Task OnModuleLoaded()
8081
{
81-
//await View3D1.Import3DModelAsync(
82-
// Import3DFormats.Fbx,
83-
// "https://threejs.org/examples/models/fbx/Samba%20Dancing.fbx",
84-
// null,
85-
// loadedObjectGuid);
86-
// await View3D1.SetCameraPositionAsync(new Vector3(0, 100, 250), new Vector3(0, 50, 0));
82+
//await View3D1.Import3DModelAsync(
83+
// Import3DFormats.Fbx,
84+
// "https://threejs.org/examples/models/fbx/Samba%20Dancing.fbx",
85+
// null,
86+
// loadedObjectGuid);
87+
// await View3D1.SetCameraPositionAsync(new Vector3(0, 100, 250), new Vector3(0, 50, 0));
8788
}
8889

8990
private void AddLights()
@@ -344,11 +345,16 @@
344345
await View3D1.RemoveByUuidAsync(last.Uuid);
345346
}
346347
}
347-
public void Dispose()
348-
{
349-
View3D1.ObjectSelected -= OnObjectSelected;
350-
View3D1.ObjectLoaded -= OnObjectLoaded;
351-
View3D1.JsModuleLoaded -= OnModuleLoaded;
352-
}
348+
349+
private async Task OnShowCameraInfo()
350+
{
351+
await View3D1.ShowCurrentCameraInfo();
352+
}
353+
public void Dispose()
354+
{
355+
View3D1.ObjectSelected -= OnObjectSelected;
356+
View3D1.ObjectLoaded -= OnObjectLoaded;
357+
View3D1.JsModuleLoaded -= OnModuleLoaded;
358+
}
353359
}
354360

src/javascript/Builders/HelperBuilder.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class HelperBuilder {
3030
}
3131

3232
if (options.type == "AxesHelper") {
33-
console.log(options);
3433
const axes = new THREE.AxesHelper(options.size);
3534
axes.uuid = options.uuid;
3635
Transforms.setPosition(axes, options.position);
@@ -65,7 +64,6 @@ class HelperBuilder {
6564
}
6665

6766
if (options.type == "PolarGridHelper") {
68-
console.log(options);
6967
const grid = new THREE.PolarGridHelper(
7068
options.radius,
7169
options.radials,
@@ -82,7 +80,6 @@ class HelperBuilder {
8280
}
8381

8482
if (options.type == "PlaneHelper") {
85-
console.log(options);
8683
let { x, y, z } = options.plane.normal;
8784
let normal = new THREE.Vector3(x, y, z);
8885
let plane = new THREE.Plane(normal, options.plane.constant);

src/javascript/Builders/LightBuilder.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class LightBuilder {
1616
options.decay
1717
);
1818
light.uuid = options.uuid;
19-
console.log("plight", light.uuid);
2019
Transforms.setPosition(light, options.position);
2120
return light;
2221
}

src/javascript/Builders/MaterialBuilder.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ class MaterialBuilder {
88
flatShading : options.flatShading,
99
metalness: options.metalness,
1010
roughness: options.roughness,
11-
wireframe: options.wireframe,
12-
wireframeLinewidth: options.wireframeLinewidth
11+
wireframe: options.wireframe
1312
});
1413
material.uuid = options.uuid;
1514
return material;

src/javascript/Viewer/Exporters.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function saveArrayBuffer(buffer, filename) {
2121

2222
class Exporters {
2323
static exportOBJ(input) {
24-
console.log("export as obj");
2524
const objExporter = new OBJExporter();
2625
const result = objExporter.parse(input);
2726
saveString(result, "scene.obj");
@@ -31,10 +30,8 @@ class Exporters {
3130
const gltfExporter = new GLTFExporter();
3231
gltfExporter.parse(input, function (result) {
3332
if (result instanceof ArrayBuffer) {
34-
console.log("export as glb");
3533
saveArrayBuffer(result, "scene.glb");
3634
} else {
37-
console.log("export as gltf");
3835
const output = JSON.stringify(result, null, 2);
3936
saveString(output, "scene.gltf");
4037
}

src/javascript/Viewer/Viewer3D.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ class Viewer3D {
136136
this.setOrbitControls();
137137
}
138138

139+
showCurrentCameraInfo() {
140+
console.log('Current camera info:', this.camera);
141+
console.log('Orbit controls info:', this.controls);
142+
}
143+
139144
setOrbitControls() {
140145
this.controls = new OrbitControls(this.camera, this.renderer.domElement);
141146
this.controls.screenSpacePanning = true;

0 commit comments

Comments
 (0)