sceneview-mcp 4.0.14 → 4.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/generated/llms-txt.js +1 -1
- package/dist/generated/symbols.js +8638 -0
- package/dist/generated/version.js +6 -2
- package/dist/guides.js +1 -1
- package/dist/platform-setup.js +125 -57
- package/dist/symbols.js +204 -0
- package/dist/tools/definitions.js +1 -1
- package/dist/tools/handler.js +1 -1
- package/dist/validator.js +199 -0
- package/package.json +4 -4
|
@@ -4,5 +4,9 @@
|
|
|
4
4
|
// build time so the MCP server, telemetry, and the install-snippet
|
|
5
5
|
// generators all report the actually-published versions instead of
|
|
6
6
|
// stale hardcoded constants. See #941.
|
|
7
|
-
export const PACKAGE_VERSION = "4.0.
|
|
8
|
-
export const LATEST_SCENEVIEW_RELEASE = "4.
|
|
7
|
+
export const PACKAGE_VERSION = "4.0.16";
|
|
8
|
+
export const LATEST_SCENEVIEW_RELEASE = "4.30.0";
|
|
9
|
+
// The pub.dev coordinate for `flutter_sceneview`, read from the plugin's
|
|
10
|
+
// README. Deliberately NOT LATEST_SCENEVIEW_RELEASE: pub.dev lags the SDK,
|
|
11
|
+
// and a caret range against an unpublished version cannot be resolved.
|
|
12
|
+
export const LATEST_FLUTTER_PUB_RELEASE = "4.24.0";
|
package/dist/guides.js
CHANGED
|
@@ -33,7 +33,7 @@ KMP shares **logic**, not **rendering**. Each platform uses its native renderer.
|
|
|
33
33
|
- **3D rendering** via Google Filament: PBR materials, HDR environments, glTF/GLB models, post-processing.
|
|
34
34
|
- **AR** via ARCore: plane detection, hit testing, anchors, cloud anchors, augmented images, depth, light estimation, point cloud.
|
|
35
35
|
- **Compose-native DSL**: all nodes are \`@Composable\` functions inside \`SceneView { }\` or \`ARSceneView { }\`.
|
|
36
|
-
- **
|
|
36
|
+
- **46+ node types**: ModelNode, LightNode, AnchorNode, CameraNode, TextNode, PathNode, ViewNode, PlaneNode, SphereNode, CylinderNode, CubeNode, DynamicSkyNode, FogNode, ReflectionProbeNode, PhysicsNode, BillboardNode, LineNode, and more.
|
|
37
37
|
|
|
38
38
|
## Apple — Alpha (SceneViewSwift)
|
|
39
39
|
|
package/dist/platform-setup.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Setup guides for every supported SceneView platform.
|
|
5
5
|
* Consolidates Android, iOS, Web, Flutter, React Native, Desktop, and TV.
|
|
6
6
|
*/
|
|
7
|
-
import { LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
|
|
7
|
+
import { LATEST_FLUTTER_PUB_RELEASE, LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
|
|
8
8
|
export const PLATFORM_IDS = ["android", "ios", "web", "flutter", "react-native", "desktop", "tv"];
|
|
9
9
|
const ANDROID_3D = `## SceneView Android — 3D Setup
|
|
10
10
|
|
|
@@ -414,18 +414,14 @@ SceneView Flutter uses **PlatformView** to embed native SceneView (Android: Fila
|
|
|
414
414
|
|
|
415
415
|
### 1. Dependencies
|
|
416
416
|
|
|
417
|
-
> **Note:** the
|
|
418
|
-
> (
|
|
419
|
-
>
|
|
417
|
+
> **Note:** the plugin is published on pub.dev as \`flutter_sceneview\`
|
|
418
|
+
> (the pub.dev names \`sceneview\` and \`sceneview_flutter\` are unrelated
|
|
419
|
+
> third-party uploads — do not use them).
|
|
420
420
|
|
|
421
421
|
\`\`\`yaml
|
|
422
422
|
# pubspec.yaml
|
|
423
423
|
dependencies:
|
|
424
|
-
|
|
425
|
-
git:
|
|
426
|
-
url: https://github.com/sceneview/sceneview
|
|
427
|
-
path: flutter/sceneview_flutter
|
|
428
|
-
ref: v${LATEST_SCENEVIEW_RELEASE}
|
|
424
|
+
flutter_sceneview: ^${LATEST_FLUTTER_PUB_RELEASE}
|
|
429
425
|
\`\`\`
|
|
430
426
|
|
|
431
427
|
### 2. Android Setup
|
|
@@ -445,32 +441,60 @@ android {
|
|
|
445
441
|
|
|
446
442
|
### 3. iOS Setup
|
|
447
443
|
|
|
448
|
-
|
|
444
|
+
Both lines in \`ios/Podfile\` are required — skipping the second one fails the
|
|
445
|
+
build with \`Unable to find a specification for 'SceneViewSwift'\`:
|
|
446
|
+
|
|
449
447
|
\`\`\`ruby
|
|
450
448
|
platform :ios, '18.0'
|
|
449
|
+
|
|
450
|
+
target 'Runner' do
|
|
451
|
+
use_frameworks!
|
|
452
|
+
pod 'SceneViewSwift',
|
|
453
|
+
:podspec => 'https://raw.githubusercontent.com/sceneview/sceneview/main/SceneViewSwift.podspec'
|
|
454
|
+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
|
455
|
+
end
|
|
451
456
|
\`\`\`
|
|
452
457
|
|
|
458
|
+
Adding \`SceneViewSwift\` as a **Swift package** in Xcode does not work: the bridge
|
|
459
|
+
is itself a pod and compiles inside the generated \`Pods.xcodeproj\`, which cannot
|
|
460
|
+
see a package added to \`Runner.xcodeproj\`. \`:podspec\` reads from the mutable
|
|
461
|
+
\`main\` branch because no released tag carries the root podspec yet; the sources
|
|
462
|
+
it pulls are tag-pinned via \`s.source\`, and this becomes a tagged coordinate once
|
|
463
|
+
a release includes it.
|
|
464
|
+
|
|
453
465
|
### 4. Basic 3D Scene
|
|
454
466
|
|
|
455
467
|
\`\`\`dart
|
|
456
|
-
import 'package:
|
|
468
|
+
import 'package:flutter/foundation.dart' show TargetPlatform, defaultTargetPlatform;
|
|
469
|
+
import 'package:flutter_sceneview/flutter_sceneview.dart';
|
|
457
470
|
|
|
458
471
|
class My3DScreen extends StatelessWidget {
|
|
459
472
|
@override
|
|
460
473
|
Widget build(BuildContext context) {
|
|
474
|
+
// Not one path for both: Filament reads glTF/GLB, RealityKit reads USDZ and
|
|
475
|
+
// cannot read glTF at all. A hardcoded .glb compiles and renders nothing on iOS.
|
|
476
|
+
// Branch on defaultTargetPlatform, never on dart:io's Platform — importing
|
|
477
|
+
// dart:io makes the file uncompilable on Flutter web.
|
|
478
|
+
final model = defaultTargetPlatform == TargetPlatform.iOS
|
|
479
|
+
? 'models/chair.usdz'
|
|
480
|
+
: 'models/chair.glb';
|
|
481
|
+
|
|
461
482
|
return SceneView(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
483
|
+
initialModels: [
|
|
484
|
+
ModelNode(modelPath: model, x: 0, y: 0, z: -2, scale: 1.0),
|
|
485
|
+
],
|
|
486
|
+
// Android only today — the iOS path is wired but no entity resolves, so
|
|
487
|
+
// this never fires (#3045). Not the shared RealityKit hit test: React
|
|
488
|
+
// Native reaches the same hook and fires on iOS (#3086).
|
|
489
|
+
onTap: (nodeName) => print('tapped: \$nodeName'),
|
|
469
490
|
);
|
|
470
491
|
}
|
|
471
492
|
}
|
|
472
493
|
\`\`\`
|
|
473
494
|
|
|
495
|
+
For imperative loading, attach a \`SceneViewController\` via \`onViewCreated\` and
|
|
496
|
+
call \`loadModel\` / \`setEnvironment\` / \`clearScene\` on it.
|
|
497
|
+
|
|
474
498
|
### 5. Platform Differences
|
|
475
499
|
|
|
476
500
|
| Feature | Android | iOS |
|
|
@@ -483,13 +507,9 @@ const FLUTTER_AR = `## SceneView Flutter — AR Setup
|
|
|
483
507
|
### 1. Dependencies
|
|
484
508
|
|
|
485
509
|
\`\`\`yaml
|
|
486
|
-
#
|
|
510
|
+
# pubspec.yaml — published on pub.dev (the names sceneview / sceneview_flutter are unrelated third-party uploads)
|
|
487
511
|
dependencies:
|
|
488
|
-
|
|
489
|
-
git:
|
|
490
|
-
url: https://github.com/sceneview/sceneview
|
|
491
|
-
path: flutter/sceneview_flutter
|
|
492
|
-
ref: v${LATEST_SCENEVIEW_RELEASE}
|
|
512
|
+
flutter_sceneview: ^${LATEST_FLUTTER_PUB_RELEASE}
|
|
493
513
|
\`\`\`
|
|
494
514
|
|
|
495
515
|
### 2. Android Manifest
|
|
@@ -502,29 +522,50 @@ dependencies:
|
|
|
502
522
|
</application>
|
|
503
523
|
\`\`\`
|
|
504
524
|
|
|
505
|
-
### 3. iOS
|
|
525
|
+
### 3. iOS Setup
|
|
526
|
+
|
|
527
|
+
Both lines in \`ios/Podfile\` are required — skipping the second one fails the
|
|
528
|
+
build with \`Unable to find a specification for 'SceneViewSwift'\`:
|
|
529
|
+
|
|
530
|
+
\`\`\`ruby
|
|
531
|
+
platform :ios, '18.0'
|
|
532
|
+
|
|
533
|
+
target 'Runner' do
|
|
534
|
+
use_frameworks!
|
|
535
|
+
pod 'SceneViewSwift',
|
|
536
|
+
:podspec => 'https://raw.githubusercontent.com/sceneview/sceneview/main/SceneViewSwift.podspec'
|
|
537
|
+
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
|
538
|
+
end
|
|
539
|
+
\`\`\`
|
|
540
|
+
|
|
541
|
+
Adding \`SceneViewSwift\` as a **Swift package** in Xcode does not work: the bridge
|
|
542
|
+
is itself a pod and compiles inside the generated \`Pods.xcodeproj\`, which cannot
|
|
543
|
+
see a package added to \`Runner.xcodeproj\`. \`:podspec\` reads from the mutable
|
|
544
|
+
\`main\` branch because no released tag carries the root podspec yet; the sources
|
|
545
|
+
it pulls are tag-pinned via \`s.source\`, and this becomes a tagged coordinate once
|
|
546
|
+
a release includes it.
|
|
547
|
+
|
|
548
|
+
### 4. iOS Info.plist
|
|
506
549
|
|
|
507
550
|
\`\`\`xml
|
|
508
551
|
<key>NSCameraUsageDescription</key>
|
|
509
552
|
<string>This app uses the camera for augmented reality.</string>
|
|
510
553
|
\`\`\`
|
|
511
554
|
|
|
512
|
-
###
|
|
555
|
+
### 5. Basic AR Scene
|
|
513
556
|
|
|
514
557
|
\`\`\`dart
|
|
515
|
-
import 'package:
|
|
558
|
+
import 'package:flutter_sceneview/flutter_sceneview.dart';
|
|
516
559
|
|
|
517
560
|
class MyARScreen extends StatelessWidget {
|
|
518
561
|
@override
|
|
519
562
|
Widget build(BuildContext context) {
|
|
520
563
|
return ARSceneView(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
print('Object placed at: \${anchor.position}');
|
|
527
|
-
},
|
|
564
|
+
planeDetection: true,
|
|
565
|
+
onPlaneDetected: (planeType) => print('plane: \$planeType'),
|
|
566
|
+
// Android only: SceneViewSwift's ARSceneView exposes no entity
|
|
567
|
+
// hit-test hook, so on iOS this never fires (#2051).
|
|
568
|
+
onTap: (nodeName) => print('tapped: \$nodeName'),
|
|
528
569
|
);
|
|
529
570
|
}
|
|
530
571
|
}
|
|
@@ -537,6 +578,8 @@ SceneView React Native uses **Fabric/Turbo** to bridge to native SceneView.
|
|
|
537
578
|
|
|
538
579
|
\`\`\`bash
|
|
539
580
|
npm install @sceneview/react-native
|
|
581
|
+
# iOS: edit ios/Podfile as in step 3 FIRST — a stock Podfile makes this
|
|
582
|
+
# \`pod install\` fail with "Unable to find a specification for 'SceneViewSwift'"
|
|
540
583
|
cd ios && pod install
|
|
541
584
|
\`\`\`
|
|
542
585
|
|
|
@@ -553,9 +596,16 @@ android {
|
|
|
553
596
|
|
|
554
597
|
### 3. iOS Setup
|
|
555
598
|
|
|
556
|
-
In \`ios/Podfile
|
|
599
|
+
In \`ios/Podfile\` — both lines, before \`pod install\`. \`SceneViewSwift\` is not on
|
|
600
|
+
the CocoaPods trunk, so the module's \`s.dependency\` on it cannot resolve without
|
|
601
|
+
an explicit coordinate (use \`:path => '<repo-root>'\` from a checkout), and a
|
|
602
|
+
stock React Native Podfile's 13.4 target is below its iOS 18.0 floor. A Swift
|
|
603
|
+
package added in Xcode does not work here: this module compiles inside
|
|
604
|
+
\`Pods.xcodeproj\`, which cannot see the host project's packages.
|
|
557
605
|
\`\`\`ruby
|
|
558
606
|
platform :ios, '18.0'
|
|
607
|
+
pod 'SceneViewSwift',
|
|
608
|
+
:podspec => 'https://raw.githubusercontent.com/sceneview/sceneview/main/SceneViewSwift.podspec'
|
|
559
609
|
\`\`\`
|
|
560
610
|
|
|
561
611
|
### 4. Basic 3D Scene
|
|
@@ -567,11 +617,12 @@ export default function My3DScreen() {
|
|
|
567
617
|
return (
|
|
568
618
|
<SceneView
|
|
569
619
|
style={{ flex: 1 }}
|
|
570
|
-
|
|
571
|
-
environment=
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
620
|
+
modelNodes={[{ src: 'models/chair.glb', position: [0, 0, -1], scale: 1.0 }]}
|
|
621
|
+
environment="environments/sky_2k.hdr"
|
|
622
|
+
cameraControlMode="orbit"
|
|
623
|
+
// Fires on Android and iOS — the iOS half is measured (#3086). Only the
|
|
624
|
+
// Flutter bridge's 3D onTap is still dead on iOS (#3045).
|
|
625
|
+
onTap={(e) => console.log(e.nativeEvent.nodeName)}
|
|
575
626
|
/>
|
|
576
627
|
);
|
|
577
628
|
}
|
|
@@ -588,6 +639,19 @@ const REACT_NATIVE_AR = `## SceneView React Native — AR Setup
|
|
|
588
639
|
|
|
589
640
|
### 1. Install
|
|
590
641
|
|
|
642
|
+
Both \`ios/Podfile\` lines are required before \`pod install\`: \`SceneViewSwift\` is
|
|
643
|
+
not on the CocoaPods trunk, so the module's \`s.dependency\` on it cannot resolve
|
|
644
|
+
without an explicit coordinate, and a stock React Native Podfile's 13.4
|
|
645
|
+
deployment target is below its iOS 18.0 floor. A Swift package added in Xcode
|
|
646
|
+
does not replace that line — this module compiles inside \`Pods.xcodeproj\`,
|
|
647
|
+
which cannot see the host project's packages.
|
|
648
|
+
|
|
649
|
+
\`\`\`ruby
|
|
650
|
+
platform :ios, '18.0'
|
|
651
|
+
pod 'SceneViewSwift',
|
|
652
|
+
:podspec => 'https://raw.githubusercontent.com/sceneview/sceneview/main/SceneViewSwift.podspec'
|
|
653
|
+
\`\`\`
|
|
654
|
+
|
|
591
655
|
\`\`\`bash
|
|
592
656
|
npm install @sceneview/react-native
|
|
593
657
|
cd ios && pod install
|
|
@@ -621,11 +685,16 @@ export default function MyARScreen() {
|
|
|
621
685
|
return (
|
|
622
686
|
<ARSceneView
|
|
623
687
|
style={{ flex: 1 }}
|
|
624
|
-
|
|
625
|
-
planeDetection=
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
688
|
+
modelNodes={[{ src: 'models/robot.glb', scale: 0.5 }]}
|
|
689
|
+
planeDetection={true}
|
|
690
|
+
// Declared so the API surface is stable, but NOT bridged natively yet:
|
|
691
|
+
// setting it true changes nothing today (#909). Left explicitly false so
|
|
692
|
+
// nobody ships an app that silently expects LiDAR occlusion.
|
|
693
|
+
depthOcclusion={false}
|
|
694
|
+
onPlaneDetected={(e) => console.log(e.nativeEvent.type)}
|
|
695
|
+
// Android only: SceneViewSwift's ARSceneView exposes no entity
|
|
696
|
+
// hit-test hook, so on iOS this never fires (#2051).
|
|
697
|
+
onTap={(e) => console.log(e.nativeEvent.nodeName)}
|
|
629
698
|
/>
|
|
630
699
|
);
|
|
631
700
|
}
|
|
@@ -645,32 +714,31 @@ plugins {
|
|
|
645
714
|
|
|
646
715
|
dependencies {
|
|
647
716
|
implementation(compose.desktop.currentOs)
|
|
648
|
-
|
|
717
|
+
// NOTE: there is no published \`io.github.sceneview:sceneview-desktop\`
|
|
718
|
+
// artifact. Desktop is a Compose Canvas placeholder living in
|
|
719
|
+
// \`samples/desktop-demo\`, not a library you can depend on yet.
|
|
649
720
|
}
|
|
650
721
|
\`\`\`
|
|
651
722
|
|
|
652
723
|
### 2. Basic Desktop Scene
|
|
653
724
|
|
|
725
|
+
There is no \`SceneView\` composable on desktop. The sample draws its wireframe
|
|
726
|
+
with a plain Compose \`Canvas\`, so the starting point is ordinary Compose
|
|
727
|
+
Desktop — copy \`samples/desktop-demo/src/desktopMain/kotlin/io/github/sceneview/desktop/Main.kt\`
|
|
728
|
+
rather than importing a SceneView type that does not exist.
|
|
729
|
+
|
|
654
730
|
\`\`\`kotlin
|
|
655
731
|
import androidx.compose.ui.window.Window
|
|
656
732
|
import androidx.compose.ui.window.application
|
|
657
|
-
import { LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
|
|
658
733
|
|
|
659
734
|
fun main() = application {
|
|
660
735
|
Window(
|
|
661
736
|
onCloseRequest = ::exitApplication,
|
|
662
737
|
title = "SceneView Desktop"
|
|
663
738
|
) {
|
|
664
|
-
//
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
shapes = listOf(
|
|
668
|
-
WireframeCube(position = Float3(0f, 0f, 0f), size = 1f),
|
|
669
|
-
WireframeSphere(position = Float3(2f, 0f, 0f), radius = 0.5f)
|
|
670
|
-
),
|
|
671
|
-
cameraOrbit = true,
|
|
672
|
-
backgroundColor = Color(0xFF1A1A2E)
|
|
673
|
-
)
|
|
739
|
+
// From samples/desktop-demo — a Compose Canvas animating a wireframe,
|
|
740
|
+
// NOT a Filament scene. The only public entry point that exists today.
|
|
741
|
+
WireframeCubeViewer()
|
|
674
742
|
}
|
|
675
743
|
}
|
|
676
744
|
\`\`\`
|
package/dist/symbols.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol-existence lookups over the generated public-API index (#2760).
|
|
3
|
+
*
|
|
4
|
+
* The index (`src/generated/symbols.ts`) is parsed from the committed
|
|
5
|
+
* binary-compatibility `.api` dumps at build time — see
|
|
6
|
+
* `scripts/generate-symbols.js` for the full provenance chain. Everything
|
|
7
|
+
* here answers one question for the validator: "does this identifier exist
|
|
8
|
+
* in the real Android/KMP SceneView API?", with edit-distance suggestions
|
|
9
|
+
* when it doesn't.
|
|
10
|
+
*
|
|
11
|
+
* Scope, stated honestly: the dumps cover `sceneview`, `arsceneview` and
|
|
12
|
+
* `sceneview-core` (Android/KMP). SceneViewSwift and sceneview-web have no
|
|
13
|
+
* committed dump, so Swift/Web snippets are NOT symbol-checked.
|
|
14
|
+
*/
|
|
15
|
+
import { SYMBOLS } from "./generated/symbols.js";
|
|
16
|
+
export const SCENEVIEW_NAMESPACE = "io.github.sceneview";
|
|
17
|
+
// ─── Lazily-built lookup sets ────────────────────────────────────────────────
|
|
18
|
+
let typeNamesCache = null;
|
|
19
|
+
let classBySimpleNameCache = null;
|
|
20
|
+
/**
|
|
21
|
+
* Every PascalCase identifier a Kotlin user can legitimately reference as a
|
|
22
|
+
* type or declarative factory:
|
|
23
|
+
* - class simple names (`ModelNode`, `WallPlacement`, …),
|
|
24
|
+
* - PascalCase top-level functions — the composables (`SceneView`,
|
|
25
|
+
* `ARSceneView`, `WallPlacementScene`, `DynamicSkyNode`, …),
|
|
26
|
+
* - PascalCase members of the `*Scope` classes — the declarative node
|
|
27
|
+
* factories (`SceneScope.ModelNode`, `ARSceneScope.…`).
|
|
28
|
+
*/
|
|
29
|
+
export function knownTypeNames() {
|
|
30
|
+
if (typeNamesCache)
|
|
31
|
+
return typeNamesCache;
|
|
32
|
+
const names = new Set();
|
|
33
|
+
for (const fqcn of Object.keys(SYMBOLS.classes)) {
|
|
34
|
+
const simple = fqcn.slice(fqcn.lastIndexOf(".") + 1);
|
|
35
|
+
if (/^[A-Z]/.test(simple))
|
|
36
|
+
names.add(simple);
|
|
37
|
+
}
|
|
38
|
+
for (const name of Object.keys(SYMBOLS.topLevel)) {
|
|
39
|
+
if (/^[A-Z]/.test(name))
|
|
40
|
+
names.add(name);
|
|
41
|
+
}
|
|
42
|
+
for (const [fqcn, entry] of Object.entries(SYMBOLS.classes)) {
|
|
43
|
+
if (!fqcn.endsWith("Scope"))
|
|
44
|
+
continue;
|
|
45
|
+
for (const member of entry.members) {
|
|
46
|
+
if (/^[A-Z]/.test(member))
|
|
47
|
+
names.add(member);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
typeNamesCache = names;
|
|
51
|
+
return names;
|
|
52
|
+
}
|
|
53
|
+
/** Class simple name → the FQCNs that declare it (usually exactly one). */
|
|
54
|
+
function classBySimpleName() {
|
|
55
|
+
if (classBySimpleNameCache)
|
|
56
|
+
return classBySimpleNameCache;
|
|
57
|
+
const map = new Map();
|
|
58
|
+
for (const fqcn of Object.keys(SYMBOLS.classes)) {
|
|
59
|
+
const simple = fqcn.slice(fqcn.lastIndexOf(".") + 1);
|
|
60
|
+
const list = map.get(simple);
|
|
61
|
+
if (list)
|
|
62
|
+
list.push(fqcn);
|
|
63
|
+
else
|
|
64
|
+
map.set(simple, [fqcn]);
|
|
65
|
+
}
|
|
66
|
+
classBySimpleNameCache = map;
|
|
67
|
+
return map;
|
|
68
|
+
}
|
|
69
|
+
export function isKnownTypeName(name) {
|
|
70
|
+
return knownTypeNames().has(name);
|
|
71
|
+
}
|
|
72
|
+
/** Top-level function (any case) — composables and extension helpers. */
|
|
73
|
+
export function isKnownTopLevelFunction(name) {
|
|
74
|
+
return name in SYMBOLS.topLevel;
|
|
75
|
+
}
|
|
76
|
+
/** Every real `remember*` composable helper — suggestion pool for typos. */
|
|
77
|
+
export function rememberHelperNames() {
|
|
78
|
+
return Object.keys(SYMBOLS.topLevel).filter((name) => name.startsWith("remember"));
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve an `io.github.sceneview.*` import target.
|
|
82
|
+
*
|
|
83
|
+
* Returns "class" for an exact class FQCN, "package" for a package that
|
|
84
|
+
* exists (covers `import io.github.sceneview.node.*`), "member" for a
|
|
85
|
+
* `Class.member` or package-level function import, and null when nothing
|
|
86
|
+
* in the index matches. Callers must only pass SceneView-namespace paths —
|
|
87
|
+
* other namespaces are out of index scope.
|
|
88
|
+
*/
|
|
89
|
+
export function resolveImport(path) {
|
|
90
|
+
if (path in SYMBOLS.classes)
|
|
91
|
+
return "class";
|
|
92
|
+
if (SYMBOLS.packages.includes(path))
|
|
93
|
+
return "package";
|
|
94
|
+
const lastDot = path.lastIndexOf(".");
|
|
95
|
+
if (lastDot === -1)
|
|
96
|
+
return null;
|
|
97
|
+
const parent = path.slice(0, lastDot);
|
|
98
|
+
const leaf = path.slice(lastDot + 1);
|
|
99
|
+
// `import io.github.sceneview.ar.rememberARCameraStream` — a top-level
|
|
100
|
+
// function imported from a package.
|
|
101
|
+
if (SYMBOLS.packages.includes(parent) && leaf in SYMBOLS.topLevel) {
|
|
102
|
+
return "member";
|
|
103
|
+
}
|
|
104
|
+
// A nested class member — accept when the parent class exists and
|
|
105
|
+
// declares it.
|
|
106
|
+
const parentClass = SYMBOLS.classes[parent];
|
|
107
|
+
if (parentClass?.members.includes(leaf))
|
|
108
|
+
return "member";
|
|
109
|
+
// `import io.github.sceneview.node.ModelNode.Companion` — the generator
|
|
110
|
+
// folds companion members into the host class and drops the `.Companion`
|
|
111
|
+
// entry, so resolve the companion itself through its host.
|
|
112
|
+
if (leaf === "Companion" && parent in SYMBOLS.classes)
|
|
113
|
+
return "member";
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
/** Union of member/property names declared by classes with this simple name. */
|
|
117
|
+
export function membersOfClass(simpleName) {
|
|
118
|
+
const fqcns = classBySimpleName().get(simpleName);
|
|
119
|
+
if (!fqcns)
|
|
120
|
+
return null;
|
|
121
|
+
const members = new Set();
|
|
122
|
+
for (const fqcn of fqcns) {
|
|
123
|
+
for (const m of SYMBOLS.classes[fqcn].members)
|
|
124
|
+
members.add(m);
|
|
125
|
+
}
|
|
126
|
+
return members;
|
|
127
|
+
}
|
|
128
|
+
// ─── Edit-distance suggestions ───────────────────────────────────────────────
|
|
129
|
+
/** Classic Levenshtein with a band cutoff — returns Infinity past `max`. */
|
|
130
|
+
export function editDistance(a, b, max) {
|
|
131
|
+
if (Math.abs(a.length - b.length) > max)
|
|
132
|
+
return Number.POSITIVE_INFINITY;
|
|
133
|
+
const la = a.length;
|
|
134
|
+
const lb = b.length;
|
|
135
|
+
let prev = Array.from({ length: lb + 1 }, (_, i) => i);
|
|
136
|
+
let curr = new Array(lb + 1);
|
|
137
|
+
for (let i = 1; i <= la; i++) {
|
|
138
|
+
curr[0] = i;
|
|
139
|
+
let rowMin = i;
|
|
140
|
+
for (let j = 1; j <= lb; j++) {
|
|
141
|
+
const cost = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
142
|
+
curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost);
|
|
143
|
+
if (curr[j] < rowMin)
|
|
144
|
+
rowMin = curr[j];
|
|
145
|
+
}
|
|
146
|
+
if (rowMin > max)
|
|
147
|
+
return Number.POSITIVE_INFINITY;
|
|
148
|
+
[prev, curr] = [curr, prev];
|
|
149
|
+
}
|
|
150
|
+
return prev[lb] <= max ? prev[lb] : Number.POSITIVE_INFINITY;
|
|
151
|
+
}
|
|
152
|
+
/** camelCase identifier → lowercased token set (`loadModelAsync` → load,model,async). */
|
|
153
|
+
function camelTokens(name) {
|
|
154
|
+
return new Set(name
|
|
155
|
+
.split(/(?=[A-Z])/)
|
|
156
|
+
.map((t) => t.toLowerCase())
|
|
157
|
+
.filter((t) => t.length > 0));
|
|
158
|
+
}
|
|
159
|
+
/** Jaccard similarity of the camelCase token sets of two identifiers. */
|
|
160
|
+
export function tokenSimilarity(a, b) {
|
|
161
|
+
const ta = camelTokens(a);
|
|
162
|
+
const tb = camelTokens(b);
|
|
163
|
+
let inter = 0;
|
|
164
|
+
for (const t of ta)
|
|
165
|
+
if (tb.has(t))
|
|
166
|
+
inter++;
|
|
167
|
+
const union = ta.size + tb.size - inter;
|
|
168
|
+
return union === 0 ? 0 : inter / union;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Closest candidates to `name`, nearest first, by a hybrid metric:
|
|
172
|
+
* - Levenshtein within a length-scaled band (2 for short names, 3 for long)
|
|
173
|
+
* catches character typos (`ModellNode` → `ModelNode`);
|
|
174
|
+
* - camelCase token overlap (Jaccard ≥ 0.5) catches structural
|
|
175
|
+
* hallucinations that raw edit distance can't reach —
|
|
176
|
+
* `createModelInstanceAsync` → `loadModelInstanceAsync` is distance 5,
|
|
177
|
+
* but shares 3 of 5 camelCase tokens.
|
|
178
|
+
* Token matches are scored `10 × (1 − similarity)` so an exact-ish edit
|
|
179
|
+
* match always outranks a merely structural one.
|
|
180
|
+
*/
|
|
181
|
+
export function suggestClosest(name, candidates, limit = 3) {
|
|
182
|
+
const max = name.length < 12 ? 2 : 3;
|
|
183
|
+
const lower = name.toLowerCase();
|
|
184
|
+
const scored = [];
|
|
185
|
+
for (const candidate of candidates) {
|
|
186
|
+
const d = editDistance(lower, candidate.toLowerCase(), max);
|
|
187
|
+
if (d !== Number.POSITIVE_INFINITY) {
|
|
188
|
+
scored.push([candidate, d]);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const similarity = tokenSimilarity(name, candidate);
|
|
192
|
+
if (similarity >= 0.5)
|
|
193
|
+
scored.push([candidate, 10 * (1 - similarity)]);
|
|
194
|
+
}
|
|
195
|
+
scored.sort((x, y) => x[1] - y[1] || x[0].localeCompare(y[0]));
|
|
196
|
+
return scored.slice(0, limit).map(([candidate]) => candidate);
|
|
197
|
+
}
|
|
198
|
+
/** Human-readable " Did you mean …?" suffix, or "" when nothing is close. */
|
|
199
|
+
export function didYouMean(name, candidates) {
|
|
200
|
+
const close = suggestClosest(name, candidates);
|
|
201
|
+
if (close.length === 0)
|
|
202
|
+
return "";
|
|
203
|
+
return ` Did you mean ${close.map((c) => `\`${c}\``).join(", ")}?`;
|
|
204
|
+
}
|
|
@@ -72,7 +72,7 @@ export const TOOL_DEFINITIONS = [
|
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
name: "validate_code",
|
|
75
|
-
description: "Checks a Kotlin or Swift SceneView snippet for common mistakes. For Kotlin: threading violations, wrong destroy order, missing null-checks, LightNode trailing-lambda bug, deprecated 2.x APIs. For Swift: missing @MainActor, async/await patterns, missing imports, RealityKit mistakes. Language is auto-detected. Always call this before presenting generated SceneView code to the user.",
|
|
75
|
+
description: "Checks a Kotlin or Swift SceneView snippet for common mistakes. For Kotlin: symbol existence against the real public API (unknown imports, made-up node types, nonexistent loader methods — with did-you-mean suggestions), threading violations, wrong destroy order, missing null-checks, LightNode trailing-lambda bug, deprecated 2.x APIs. For Swift: missing @MainActor, async/await patterns, missing imports, RealityKit mistakes. Language is auto-detected. Always call this before presenting generated SceneView code to the user.",
|
|
76
76
|
inputSchema: {
|
|
77
77
|
type: "object",
|
|
78
78
|
properties: {
|
package/dist/tools/handler.js
CHANGED
|
@@ -697,7 +697,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
697
697
|
{ platform: "visionOS", renderer: "RealityKit", framework: "SwiftUI", status: "Alpha", version: LATEST_SCENEVIEW_RELEASE, dependency: "SceneViewSwift (SPM)", features: ["3D", "Immersive spaces", "Hand tracking (planned)"] },
|
|
698
698
|
{ platform: "Web", renderer: "Filament.js (WASM)", framework: "Kotlin/JS", status: "Alpha", version: LATEST_SCENEVIEW_RELEASE, dependency: "sceneview-web (npm)", features: ["3D", "WebXR AR/VR", "GLB models", "WebGL2"] },
|
|
699
699
|
{ platform: "Desktop", renderer: "Software / Filament JNI", framework: "Compose Desktop", status: "Alpha", version: LATEST_SCENEVIEW_RELEASE, dependency: "sceneview-desktop (local)", features: ["3D", "Software renderer", "Wireframe"] },
|
|
700
|
-
{ platform: "Flutter", renderer: "Filament / RealityKit", framework: "PlatformView", status: "Alpha", version: LATEST_SCENEVIEW_RELEASE, dependency: "flutter pub:
|
|
700
|
+
{ platform: "Flutter", renderer: "Filament / RealityKit", framework: "PlatformView", status: "Alpha", version: LATEST_SCENEVIEW_RELEASE, dependency: "flutter pub: flutter_sceneview (git ref until first publish, #2735)", features: ["3D", "AR", "Android + iOS bridge"] },
|
|
701
701
|
];
|
|
702
702
|
const lines = [
|
|
703
703
|
"## SceneView Supported Platforms\n",
|