Skip to content

Instantly share code, notes, and snippets.

View mattmacf98's full-sized avatar

Matthew MacFarquhar mattmacf98

View GitHub Profile
@mattmacf98
mattmacf98 / StandardizedTestEvent.md
Last active July 21, 2025 17:52
Definition of a common test structure for glTF KHR_interactivity test assets to utilize

Standardized KHR_interactivity testing using custom events

The structure below outlines how to configure glTF interactivity test assets using a standardized approach. It leverages a custom event with the ID onTestEnd to indicate when a test is complete and to provide result details, including information about the test outcome.

Extras Data

To help test runners understand the expected duration of a test, test assets SHOULD include a property at the graph entry level of the KHR_interactivity extension the anticipated completion time in milliseconds.

KHR_interactivity:{
  graphs: [
    {
      extras: {
        expectedTestTime: number
public class ObjectToJson {
public static void main(String[] args) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
ClassRoom classRoom1 = new ClassRoom("Math 101", Arrays.asList(new Person("Bill", 12), new Person("John", 15), new Person("Matt", 10)));
ClassRoom classRoom2 = new ClassRoom("English 101", Arrays.asList(new Person("Bob", 13), new Person("Alex", 16), new Person("Matt", 10)));
ClassRoom classRoom3 = new ClassRoom("French 101", Arrays.asList(new Person("Jill", 9), new Person("John", 15), new Person("John", 15)));
//write it
String classRoomJson = objectMapper.writeValueAsString(new ClassRoom[]{classRoom1, classRoom2, classRoom3});
public class ObjectToJson {
public static void main(String[] args) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
ClassRoom classRoom1 = new ClassRoom("Math 101", Arrays.asList(new Person("Bill", 12), new Person("John", 15), new Person("Matt", 10)));
ClassRoom classRoom2 = new ClassRoom("English 101", Arrays.asList(new Person("Bob", 13), new Person("Alex", 16), new Person("Matt", 10)));
ClassRoom classRoom3 = new ClassRoom("French 101", Arrays.asList(new Person("Jill", 9), new Person("John", 15), new Person("John", 15)));
//write it
String classRoomJson = objectMapper.writeValueAsString(new ClassRoom[]{classRoom1, classRoom2, classRoom3});
System.out.println(classRoomJson);
public class Person {
private String name;
private int age;
public Person() {
}
public Person(String name, int age) {
this.name = name;
public class ClassRoom {
private String className;
private List<Person> members;
public ClassRoom() {
}
public ClassRoom(String className, List<Person> members) {
this.className = className;
this.members = members;
public class ParseJson {
public static void main(String[] args) throws IOException {
File jsonFile = new File("src/main/java/parsejson/jsonExample");
String content = readFile(jsonFile);
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(content);
jsonNode.get("restaurants").forEach(
(restaurant)->{restaurant.get("menu").get("menuitem").forEach(
public class ParseJson {
public static void main(String[] args) throws IOException {
File jsonFile = new File("src/main/java/parsejson/jsonExample");
String content = readFile(jsonFile);
}
public static String readFile(File file) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder stringBuilder = new StringBuilder();
String line;