update materials_and_textures example
This commit is contained in:
@@ -54,8 +54,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
_viewer = viewer;
|
_viewer = viewer;
|
||||||
await _viewer!.setPostProcessing(true);
|
await _viewer!.setPostProcessing(true);
|
||||||
|
|
||||||
_unlitMaterial = await _viewer!.createUnlitMaterialInstance();
|
_unlitMaterial =
|
||||||
_litMaterial = await _viewer!.createUbershaderMaterialInstance();
|
await FilamentApp.instance!.createUnlitMaterialInstance();
|
||||||
|
_litMaterial =
|
||||||
|
await FilamentApp.instance!.createUbershaderMaterialInstance();
|
||||||
await _viewer!.addDirectLight(
|
await _viewer!.addDirectLight(
|
||||||
DirectLight.sun(
|
DirectLight.sun(
|
||||||
intensity: 50000,
|
intensity: 50000,
|
||||||
@@ -81,7 +83,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
materialInstances: [_unlitMaterial],
|
materialInstances: [_unlitMaterial],
|
||||||
);
|
);
|
||||||
|
|
||||||
await _viewer!.setCameraPosition(0, 0, 5);
|
final view = await viewer.getActiveCamera();
|
||||||
|
await view.lookAt(Vector3(0, 0, 5));
|
||||||
|
|
||||||
await _viewer!.setRendering(true);
|
await _viewer!.setRendering(true);
|
||||||
setState(() {});
|
setState(() {});
|
||||||
});
|
});
|
||||||
@@ -95,18 +99,18 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
await materialInstance.setParameterInt("baseColorIndex", 0);
|
await materialInstance.setParameterInt("baseColorIndex", 0);
|
||||||
var imageBuffer = await rootBundle.load("assets/background.png");
|
var imageBuffer = await rootBundle.load("assets/background.png");
|
||||||
var imageData = imageBuffer.buffer.asUint8List(imageBuffer.offsetInBytes);
|
var imageData = imageBuffer.buffer.asUint8List(imageBuffer.offsetInBytes);
|
||||||
_image = await _viewer!.decodeImage(imageData);
|
_image = await FilamentApp.instance!.decodeImage(imageData);
|
||||||
var width = await _image!.getWidth();
|
var width = await _image!.getWidth();
|
||||||
var height = await _image!.getHeight();
|
var height = await _image!.getHeight();
|
||||||
|
|
||||||
_texture = await _viewer!.createTexture(width, height);
|
_texture = await FilamentApp.instance!.createTexture(width, height);
|
||||||
await _texture!.setLinearImage(
|
await _texture!.setLinearImage(
|
||||||
_image!,
|
_image!,
|
||||||
PixelDataFormat.RGBA,
|
PixelDataFormat.RGBA,
|
||||||
PixelDataType.FLOAT,
|
PixelDataType.FLOAT,
|
||||||
);
|
);
|
||||||
|
|
||||||
final textureSampler = await _viewer!.createTextureSampler();
|
final textureSampler = await FilamentApp.instance!.createTextureSampler();
|
||||||
await materialInstance.setParameterTexture(
|
await materialInstance.setParameterTexture(
|
||||||
"baseColorMap",
|
"baseColorMap",
|
||||||
_texture!,
|
_texture!,
|
||||||
@@ -134,7 +138,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
if (_viewer != null) ...[
|
if (_viewer != null) ...[
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: ThermionListenerWidget(
|
child: ThermionListenerWidget(
|
||||||
inputHandler: DelegateInputHandler.fixedOrbit(_viewer!),
|
inputHandler: DelegateInputHandler.fixedOrbit(_viewer!, sensitivity: InputSensitivityOptions(mouseSensitivity: 0.01)),
|
||||||
child: ThermionWidget(viewer: _viewer!),
|
child: ThermionWidget(viewer: _viewer!),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -156,9 +160,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
unlit = !unlit;
|
unlit = !unlit;
|
||||||
setState(() {
|
setState(() {});
|
||||||
|
|
||||||
});
|
|
||||||
await _asset.setMaterialInstanceAt(
|
await _asset.setMaterialInstanceAt(
|
||||||
unlit ? _unlitMaterial : _litMaterial,
|
unlit ? _unlitMaterial : _litMaterial,
|
||||||
);
|
);
|
||||||
@@ -168,8 +170,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var materialInstance = await _viewer!
|
var materialInstance =
|
||||||
.getMaterialInstanceAt(_asset.entity, 0);
|
await _asset.getMaterialInstanceAt();
|
||||||
await _setMaterialTexture(materialInstance);
|
await _setMaterialTexture(materialInstance);
|
||||||
},
|
},
|
||||||
child: Text("Apply texture"),
|
child: Text("Apply texture"),
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ EXTERNAL SOURCES:
|
|||||||
:path: Flutter/ephemeral/.symlinks/plugins/thermion_flutter/macos
|
:path: Flutter/ephemeral/.symlinks/plugins/thermion_flutter/macos
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
|
||||||
thermion_flutter: debb51a861788780ce40e11e4400c2e5a8681fdf
|
thermion_flutter: debb51a861788780ce40e11e4400c2e5a8681fdf
|
||||||
|
|
||||||
PODFILE CHECKSUM: 1888651be91a8ad58692c1add9ce24279fd4e950
|
PODFILE CHECKSUM: 1888651be91a8ad58692c1add9ce24279fd4e950
|
||||||
|
|||||||
@@ -558,7 +558,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
@@ -641,7 +641,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
@@ -691,7 +691,7 @@
|
|||||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
|
|||||||
@@ -11,14 +11,7 @@ dependencies:
|
|||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
cupertino_icons: ^1.0.8
|
cupertino_icons: ^1.0.8
|
||||||
thermion_dart:
|
|
||||||
path: ../../../thermion_dart
|
|
||||||
thermion_flutter:
|
thermion_flutter:
|
||||||
path: ../../../thermion_flutter/thermion_flutter
|
|
||||||
thermion_flutter_method_channel:
|
|
||||||
path: ../../../thermion_flutter/thermion_flutter_method_channel
|
|
||||||
thermion_flutter_platform_interface:
|
|
||||||
path: ../../../thermion_flutter/thermion_flutter_platform_interface
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -35,6 +28,8 @@ dependency_overrides:
|
|||||||
path: ../../../thermion_flutter/thermion_flutter_method_channel
|
path: ../../../thermion_flutter/thermion_flutter_method_channel
|
||||||
thermion_flutter_platform_interface:
|
thermion_flutter_platform_interface:
|
||||||
path: ../../../thermion_flutter/thermion_flutter_platform_interface
|
path: ../../../thermion_flutter/thermion_flutter_platform_interface
|
||||||
|
thermion_flutter_web:
|
||||||
|
path: ../../../thermion_flutter/thermion_flutter_web
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
Reference in New Issue
Block a user